本文整理了Java中edu.illinois.cs.cogcomp.core.io.IOUtils.isFile()
方法的一些代码示例,展示了IOUtils.isFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.isFile()
方法的具体详情如下:
包路径:edu.illinois.cs.cogcomp.core.io.IOUtils
类名称:IOUtils
方法名:isFile
[英]Check if this the argument is a file.
[中]检查此参数是否为文件。
代码示例来源:origin: CogComp/cogcomp-nlp
/**
* Filters the files contained in a directory.
*/
public static String[] lsFiles(String directory, FilenameFilter filter) throws IOException {
File dir = new File(directory);
ArrayList<String> files = new ArrayList<>();
for (File filepath : dir.listFiles(filter)) {
if (isFile(filepath.getAbsolutePath()))
files.add(filepath.getAbsolutePath());
}
return files.toArray(new String[files.size()]);
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-core-utilities
/**
* Filters the files contained in a directory.
*/
public static String[] lsFiles(String directory, FilenameFilter filter) throws IOException {
File dir = new File(directory);
ArrayList<String> files = new ArrayList<>();
for (File filepath : dir.listFiles(filter)) {
if (isFile(filepath.getAbsolutePath()))
files.add(filepath.getAbsolutePath());
}
return files.toArray(new String[files.size()]);
}
代码示例来源:origin: CogComp/cogcomp-nlp
private List<String> getFiles(String dataDir) {
List<String> files = new ArrayList<>();
FilenameFilter xmlFilter = (dir, name) -> (name.startsWith("pp-") && name.endsWith(".xml") && IOUtils
.isFile(dir.getAbsolutePath() + File.separator + name));
String[] xmlFiles = (new File(dataDir)).list(xmlFilter);
assert xmlFiles != null;
for (String fileName : xmlFiles) {
String rawFileName = IOUtils.stripFileExtension(fileName);
files.add(rawFileName);
}
return files;
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
/**
* Delete a file
*
* @return true only if the delete was successful
*/
public static boolean rm(String file) throws IOException {
if (!exists(file))
return false;
if (!isFile(file))
throw new IOException(file + " is not a file!");
return (new File(file)).delete();
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-prep-srl
private List<String> getFiles(String dataDir) {
List<String> files = new ArrayList<>();
FilenameFilter xmlFilter = (dir, name) -> (name.startsWith("pp-") && name.endsWith(".xml") && IOUtils
.isFile(dir.getAbsolutePath() + File.separator + name));
String[] xmlFiles = (new File(dataDir)).list(xmlFilter);
assert xmlFiles != null;
for (String fileName : xmlFiles) {
String rawFileName = IOUtils.stripFileExtension(fileName);
files.add(rawFileName);
}
return files;
}
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-core-utilities
/**
* Delete a file
*
* @return true only if the delete was successful
*/
public static boolean rm(String file) throws IOException {
if (!exists(file))
return false;
if (!isFile(file))
throw new IOException(file + " is not a file!");
return (new File(file)).delete();
}
代码示例来源:origin: CogComp/cogcomp-nlp
/**
* Filters the files contained in a directory or in its subdirectory structure. Returns all
* files (not directories) that pass the filter.
*/
public static String[] lsFilesRecursive(String directory, FilenameFilter filter)
throws IOException {
File dir = new File(directory);
ArrayList<String> files = new ArrayList<>();
for (File filepath : dir.listFiles(filter)) {
if (isFile(filepath.getAbsolutePath()))
files.add(filepath.getAbsolutePath());
else if (isDirectory(filepath.getAbsolutePath()))
files.addAll(Arrays.asList(lsFilesRecursive(filepath.getAbsolutePath(), filter)));
}
return files.toArray(new String[files.size()]);
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-core-utilities
/**
* Filters the files contained in a directory or in its subdirectory structure. Returns all
* files (not directories) that pass the filter.
*/
public static String[] lsFilesRecursive(String directory, FilenameFilter filter)
throws IOException {
File dir = new File(directory);
ArrayList<String> files = new ArrayList<>();
for (File filepath : dir.listFiles(filter)) {
if (isFile(filepath.getAbsolutePath()))
files.add(filepath.getAbsolutePath());
else if (isDirectory(filepath.getAbsolutePath()))
files.addAll(Arrays.asList(lsFilesRecursive(filepath.getAbsolutePath(), filter)));
}
return files.toArray(new String[files.size()]);
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison
/**
* A table is built from either a given source corpus file or source corpus directory by
* counting the number of times that each suffix-POS association in a source corpus.
*
* @param home file name or directory name of the source corpus
* @throws Exception
**/
public void buildTable(String home) throws Exception {
if (IOUtils.isFile(home))
this.buildTableHelper(home);
else if (IOUtils.isDirectory(home)) {
String[] files = IOUtils.lsFiles(home);
for (String file : files) {
// logger.info(file);
this.buildTableHelper(home + "\\" + file);
}
}
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison
/**
* A table is built from either a given source corpus file or source corpus directory by simply
* counting the number of times that each form-POS association appear in a source corpus.
*
* @param home file name or directory name of the source corpus
* @throws Exception
**/
public void buildTable(String home) throws Exception {
if (IOUtils.isFile(home))
this.buildTableHelper(home);
else if (IOUtils.isDirectory(home)) {
String[] files = IOUtils.lsFiles(home);
for (String file : files) {
// logger.info(file);
this.buildTableHelper(home + "\\" + file);
}
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
/**
* A table is built from either a given source corpus file or source corpus directory by simply
* counting the number of times that each form-POS association appear in a source corpus.
*
* @param home file name or directory name of the source corpus
* @throws Exception
**/
public void buildTable(String home) throws Exception {
if (IOUtils.isFile(home))
this.buildTableHelper(home);
else if (IOUtils.isDirectory(home)) {
String[] files = IOUtils.lsFiles(home);
for (String file : files) {
// logger.info(file);
this.buildTableHelper(home + "\\" + file);
}
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
/**
* A table is built from either a given source corpus file or source corpus directory by
* counting the number of times that each suffix-POS association in a source corpus.
*
* @param home file name or directory name of the source corpus
* @throws Exception
**/
public void buildTable(String home) throws Exception {
if (IOUtils.isFile(home))
this.buildTableHelper(home);
else if (IOUtils.isDirectory(home)) {
String[] files = IOUtils.lsFiles(home);
for (String file : files) {
// logger.info(file);
this.buildTableHelper(home + "\\" + file);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!