当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils.iterateFiles方法代码示例

本文整理汇总了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;
}
 
开发者ID:yuantiku,项目名称:ytk-learn,代码行数:27,代码来源:LocalFileSystem.java

示例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;
}
 
开发者ID:AshokKumarMelarkot,项目名称:msa-cucumber-appium,代码行数:24,代码来源:MobileApp.java

示例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;
}
 
开发者ID:hwding,项目名称:pdf-unstamper,代码行数:10,代码来源:IOHandler.java

示例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;
}
 
开发者ID:hwding,项目名称:pdf-unstamper,代码行数:16,代码来源:IOHandler.java

示例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;
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:32,代码来源:Application.java

示例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;
}
 
开发者ID:RSNA,项目名称:dcmrs-broker,代码行数:13,代码来源:CacheReaper.java

示例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;
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:46,代码来源:CompilationManager.java


注:本文中的org.apache.commons.io.FileUtils.iterateFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。