本文整理汇总了Java中org.apache.commons.io.FileUtils.iterateFiles方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.iterateFiles方法的具体用法?Java FileUtils.iterateFiles怎么用?Java FileUtils.iterateFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.io.FileUtils
的用法示例。
在下文中一共展示了FileUtils.iterateFiles方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recurGetPaths
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Override
public List<String> recurGetPaths(List<String> paths) throws IOException {
List<String> retList = new ArrayList<>();
for (String path : paths) {
File file = new File(path);
if (!file.exists()) {
throw new IOException("path:" + path + " does not exist");
}
if (!file.isDirectory()) {
if (!file.isHidden()) {
retList.add(path);
}
} else {
Iterator<File> fileIt = FileUtils.iterateFiles(file, null, true);
while (fileIt.hasNext()) {
File afile = fileIt.next();
if (isHiddenFile(afile)) {
continue;
}
retList.add(afile.getAbsolutePath());
}
}
}
return retList;
}
示例2: getAllPages
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private static Map<String, MobileScreen> getAllPages(String filePath) throws Throwable {
Map<String, MobileScreen> pages = new HashMap<>();
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
try {
Iterator it = FileUtils.iterateFiles(new File(filePath), new String[]{"yaml"}, false);
while (it.hasNext()) {
File file = (File) it.next();
MobileScreen mobileScreen = getPage(file);
System.out.println("Name of the file : "+file.getName());
System.out.println("****** :- " + mobileScreen.getPageName());
System.out.println(ReflectionToStringBuilder.toString(mobileScreen, ToStringStyle.MULTI_LINE_STYLE));
pages.put(mobileScreen.getPageName(), mobileScreen);
}
} catch (Exception e) {
e.printStackTrace();
throw e.getCause();
}
return pages;
}
示例3: getFiles
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static Iterator<File> getFiles(
@NotNull String idn,
@NotNull boolean recursive) {
File dirI = new File(idn);
if (dirI.exists() && dirI.isDirectory()) {
return FileUtils.iterateFiles(dirI, new String[]{"pdf"}, recursive);
} else
return null;
}
示例4: getCopiedFiles
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static Iterator<File> getCopiedFiles(
@NotNull String idn,
@NotNull String odn,
@NotNull boolean recursive)
throws IOException, FileNameDuplicateException {
File dirI = new File(idn);
File dirO = new File(odn);
if (dirI.getCanonicalPath().equals(dirO.getCanonicalPath()))
throw new FileNameDuplicateException();
else if (dirI.exists() && dirI.isDirectory()) {
FileUtils.copyDirectory(dirI, dirO);
return FileUtils.iterateFiles(dirO, new String[]{"pdf"}, recursive);
} else
return null;
}
示例5: addDefinitionFilesLastModified
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private long addDefinitionFilesLastModified () {
long configFileLastModTime = 0;
if ( getDefinitionFile().exists() && getDefinitionFile().canRead() ) {
long totalTime = 0;
logger.debug( "Loading definition files in: {}", getDefinitionFolder()
.getAbsolutePath() );
@SuppressWarnings ( "unchecked" )
Iterator<File> jsFileIterator = FileUtils.iterateFiles( getDefinitionFolder(),
new String[] { "js", "json" }, false );
StringBuilder builder = null;
if ( logger.isDebugEnabled() ) {
builder = new StringBuilder();
}
while (jsFileIterator.hasNext()) {
File jsFile = jsFileIterator.next();
if ( logger.isDebugEnabled() ) {
builder.append( "\n\t" + jsFile.getAbsolutePath() );
}
totalTime += jsFile.lastModified();
}
logger.debug( "Checking filestamps for file(s): {} ", builder );
configFileLastModTime = totalTime;
} else {
logger.error( "Cannot access config file:" + getDefinitionFile().getAbsolutePath() );
}
return configFileLastModTime;
}
示例6: getLastModified
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private static long getLastModified(File studyDir)
{
long newest = Long.MIN_VALUE;
for (File file : (Iterable<File>)()-> FileUtils.iterateFiles(studyDir,
TrueFileFilter.INSTANCE,
TrueFileFilter.INSTANCE)) {
newest = Math.max(newest, file.lastModified());
}
return newest;
}
示例7: findHadoopJars
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
* locate the hadoop-*-core.jar in $HADOOP_MAPRED_HOME or
* --hadoop-mapred-home.
* If that doesn't work, check our classpath.
* @return the filename of the hadoop-*-core.jar file.
*/
private String findHadoopJars() {
String hadoopMapRedHome = options.getHadoopMapRedHome();
if (null == hadoopMapRedHome) {
LOG.info("$HADOOP_MAPRED_HOME is not set");
return Jars.getJarPathForClass(JobConf.class);
}
if (!hadoopMapRedHome.endsWith(File.separator)) {
hadoopMapRedHome = hadoopMapRedHome + File.separator;
}
File hadoopMapRedHomeFile = new File(hadoopMapRedHome);
LOG.info("HADOOP_MAPRED_HOME is " + hadoopMapRedHomeFile.getAbsolutePath());
Iterator<File> filesIterator = FileUtils.iterateFiles(hadoopMapRedHomeFile,
new String[] { "jar" }, true);
StringBuilder sb = new StringBuilder();
while (filesIterator.hasNext()) {
File file = filesIterator.next();
String name = file.getName();
if (name.startsWith("hadoop-common")
|| name.startsWith("hadoop-mapreduce-client-core")
|| name.startsWith("hadoop-core")) {
sb.append(file.getAbsolutePath());
sb.append(File.pathSeparator);
}
}
if (sb.length() < 1) {
LOG.warn("HADOOP_MAPRED_HOME appears empty or missing");
return Jars.getJarPathForClass(JobConf.class);
}
String s = sb.substring(0, sb.length() - 1);
LOG.debug("Returning jar file path " + s);
return s;
}