org.apache.commons.io.FileUtils.toSuffixes()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中org.apache.commons.io.FileUtils.toSuffixes()方法的一些代码示例,展示了FileUtils.toSuffixes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.toSuffixes()方法的具体详情如下:
包路径:org.apache.commons.io.FileUtils
类名称:FileUtils
方法名:toSuffixes

FileUtils.toSuffixes介绍

[英]Converts an array of file extensions to suffixes for use with IOFileFilters.
[中]将文件扩展名数组转换为后缀,以便与IOFileFilters一起使用。

代码示例

代码示例来源:origin: commons-io/commons-io

/**
 * Finds files within a given directory (and optionally its subdirectories)
 * which match an array of extensions.
 *
 * @param directory  the directory to search in
 * @param extensions an array of extensions, ex. {"java","xml"}. If this
 *                   parameter is {@code null}, all files are returned.
 * @param recursive  if true all subdirectories are searched as well
 * @return a collection of java.io.File with the matching files
 */
public static Collection<File> listFiles(
    final File directory, final String[] extensions, final boolean recursive) {
  IOFileFilter filter;
  if (extensions == null) {
    filter = TrueFileFilter.INSTANCE;
  } else {
    final String[] suffixes = toSuffixes(extensions);
    filter = new SuffixFileFilter(suffixes);
  }
  return listFiles(directory, filter,
      recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE);
}

代码示例来源:origin: org.apache.commons/commons-io

/**
 * Finds files within a given directory (and optionally its subdirectories)
 * which match an array of extensions.
 *
 * @param directory  the directory to search in
 * @param extensions  an array of extensions, ex. {"java","xml"}. If this
 * parameter is <code>null</code>, all files are returned.
 * @param recursive  if true all subdirectories are searched as well
 * @return an collection of java.io.File with the matching files
 */
public static Collection listFiles(
    File directory, String[] extensions, boolean recursive) {
  IOFileFilter filter;
  if (extensions == null) {
    filter = TrueFileFilter.INSTANCE;
  } else {
    String[] suffixes = toSuffixes(extensions);
    filter = new SuffixFileFilter(suffixes);
  }
  return listFiles(directory, filter,
    (recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE));
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-io

/**
 * Finds files within a given directory (and optionally its subdirectories)
 * which match an array of extensions.
 *
 * @param directory  the directory to search in
 * @param extensions  an array of extensions, ex. {"java","xml"}. If this
 * parameter is <code>null</code>, all files are returned.
 * @param recursive  if true all subdirectories are searched as well
 * @return an collection of java.io.File with the matching files
 */
public static Collection listFiles(
    File directory, String[] extensions, boolean recursive) {
  IOFileFilter filter;
  if (extensions == null) {
    filter = TrueFileFilter.INSTANCE;
  } else {
    String[] suffixes = toSuffixes(extensions);
    filter = new SuffixFileFilter(suffixes);
  }
  return listFiles(directory, filter,
    (recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE));
}

代码示例来源:origin: org.onosproject/onlab-thirdparty

/**
 * Finds files within a given directory (and optionally its subdirectories)
 * which match an array of extensions.
 *
 * @param directory  the directory to search in
 * @param extensions  an array of extensions, ex. {"java","xml"}. If this
 * parameter is {@code null}, all files are returned.
 * @param recursive  if true all subdirectories are searched as well
 * @return an collection of java.io.File with the matching files
 */
public static Collection<File> listFiles(
    File directory, String[] extensions, boolean recursive) {
  IOFileFilter filter;
  if (extensions == null) {
    filter = TrueFileFilter.INSTANCE;
  } else {
    String[] suffixes = toSuffixes(extensions);
    filter = new SuffixFileFilter(suffixes);
  }
  return listFiles(directory, filter,
    recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE);
}

代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.io

/**
 * Finds files within a given directory (and optionally its subdirectories)
 * which match an array of extensions.
 *
 * @param directory  the directory to search in
 * @param extensions  an array of extensions, ex. {"java","xml"}. If this
 * parameter is <code>null</code>, all files are returned.
 * @param recursive  if true all subdirectories are searched as well
 * @return an collection of java.io.File with the matching files
 */
public static Collection listFiles(
    File directory, String[] extensions, boolean recursive) {
  IOFileFilter filter;
  if (extensions == null) {
    filter = TrueFileFilter.INSTANCE;
  } else {
    String[] suffixes = toSuffixes(extensions);
    filter = new SuffixFileFilter(suffixes);
  }
  return listFiles(directory, filter,
    (recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE));
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Finds files within a given directory (and optionally its subdirectories)
 * which match an array of extensions.
 *
 * @param directory  the directory to search in
 * @param extensions an array of extensions, ex. {"java","xml"}. If this
 *                   parameter is {@code null}, all files are returned.
 * @param recursive  if true all subdirectories are searched as well
 * @return a collection of java.io.File with the matching files
 */
public static Collection<File> listFiles(
    final File directory, final String[] extensions, final boolean recursive) {
  IOFileFilter filter;
  if (extensions == null) {
    filter = TrueFileFilter.INSTANCE;
  } else {
    final String[] suffixes = toSuffixes(extensions);
    filter = new SuffixFileFilter(suffixes);
  }
  return listFiles(directory, filter,
      recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE);
}

代码示例来源:origin: io.github.stephenc.docker/docker-client-shaded

/**
 * Finds files within a given directory (and optionally its subdirectories)
 * which match an array of extensions.
 *
 * @param directory  the directory to search in
 * @param extensions an array of extensions, ex. {"java","xml"}. If this
 *                   parameter is {@code null}, all files are returned.
 * @param recursive  if true all subdirectories are searched as well
 * @return an collection of java.io.File with the matching files
 */
public static Collection<File> listFiles(
    final File directory, final String[] extensions, final boolean recursive) {
  IOFileFilter filter;
  if (extensions == null) {
    filter = TrueFileFilter.INSTANCE;
  } else {
    final String[] suffixes = toSuffixes(extensions);
    filter = new SuffixFileFilter(suffixes);
  }
  return listFiles(directory, filter,
      recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE);
}

代码示例来源:origin: Nextdoor/bender

/**
 * Finds files within a given directory (and optionally its subdirectories)
 * which match an array of extensions.
 *
 * @param directory  the directory to search in
 * @param extensions  an array of extensions, ex. {"java","xml"}. If this
 * parameter is <code>null</code>, all files are returned.
 * @param recursive  if true all subdirectories are searched as well
 * @return an collection of java.io.File with the matching files
 */
public static Collection<File> listFiles(
    File directory, String[] extensions, boolean recursive) {
  IOFileFilter filter;
  if (extensions == null) {
    filter = TrueFileFilter.INSTANCE;
  } else {
    String[] suffixes = toSuffixes(extensions);
    filter = new SuffixFileFilter(suffixes);
  }
  return listFiles(directory, filter,
    recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE);
}

相关文章

FileUtils类方法