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


Java FilenameFilter类代码示例

本文整理汇总了Java中java.io.FilenameFilter的典型用法代码示例。如果您正苦于以下问题:Java FilenameFilter类的具体用法?Java FilenameFilter怎么用?Java FilenameFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FilenameFilter类属于java.io包,在下文中一共展示了FilenameFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEtr

import java.io.FilenameFilter; //导入依赖的package包/类
public Collection<String> getEtr(){
	Collection<File> res = new LinkedList<File>();
	File[] listdir = new File(Engine.PROJECTS_PATH).listFiles();
	for(File s : listdir){
		File tracedir = new File(s,"Traces");
		if(tracedir.exists()&&tracedir.isDirectory()){
			File[] listconnectors = tracedir.listFiles();
			for(File s2 : listconnectors){
				res.addAll(Arrays.asList(s2.listFiles(new FilenameFilter(){
					public boolean accept(File arg0, String arg1) {
						return arg1.endsWith(".etr");
					}
				})));
			}
		}
	}
	Collection<String> listetr = new ArrayList<String>(res.size());
	for(File f : res)
		listetr.add(f.getPath().substring(Engine.PROJECTS_PATH.length()));
	return listetr;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:22,代码来源:TracePlayerManager.java

示例2: addRegionFilesToCollection

import java.io.FilenameFilter; //导入依赖的package包/类
/**
 * filters the files in the par1 directory, and adds them to the par2 collections
 */
private void addRegionFilesToCollection(File worldDir, Collection<File> collection)
{
    File file1 = new File(worldDir, "region");
    File[] afile = file1.listFiles(new FilenameFilter()
    {
        public boolean accept(File p_accept_1_, String p_accept_2_)
        {
            return p_accept_2_.endsWith(".mcr");
        }
    });

    if (afile != null)
    {
        Collections.addAll(collection, afile);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:20,代码来源:AnvilSaveConverter.java

示例3: test01

import java.io.FilenameFilter; //导入依赖的package包/类
@Test
public void test01() throws Exception {
    String basePackage = "/com.jt.core.proxy";
    basePackage = basePackage.replaceAll(".", "/");
    Enumeration<URL> resources = Thread.currentThread().getContextClassLoader().getResources(basePackage);
    while (resources.hasMoreElements()) {
        URL url = resources.nextElement();
        String file = url.getFile();
        File f = new File(file);
        if (f.exists()) {
            File[] classes = f.listFiles(new FilenameFilter() {
                @Override
                public boolean accept(File dir, String name) {
                    return name.endsWith("class");
                }
            });
            for (File c : classes) {
                System.out.println(c);
            }
        }
    }

}
 
开发者ID:jt120,项目名称:take,代码行数:24,代码来源:ProxyParseFactoryTest.java

示例4: setUp

import java.io.FilenameFilter; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  checkpointDir = new File(baseDir, "checkpoint");
  dataDir = new File(baseDir, "dataDir");
  Assert.assertTrue(checkpointDir.mkdirs() || checkpointDir.isDirectory());
  Assert.assertTrue(dataDir.mkdirs() || dataDir.isDirectory());
  File[] dataFiles = origDataDir.listFiles(new FilenameFilter() {
    @Override
    public boolean accept(File dir, String name) {
      if (name.contains("lock")) {
        return false;
      }
      return true;
    }
  });
  for (File dataFile : dataFiles) {
    Serialization.copyFile(dataFile, new File(dataDir, dataFile.getName()));
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:20,代码来源:TestFileChannelIntegrityTool.java

示例5: getAllLogFiles

import java.io.FilenameFilter; //导入依赖的package包/类
public static Collection<File> getAllLogFiles()
{
	FilenameFilter logFilter = new FilenameFilter()
	{
		public boolean accept(File dir, String name)
		{
			String lowercaseName = name.toLowerCase();
			return lowercaseName.matches("\\d\\d\\d\\d.log");
		}
	};
	File logDir = getLogDirectory();
	File[] files = logDir.listFiles(logFilter);
	if (files == null)
	{
		return new ArrayList<File>();
	}
	else
	{
		return (Collection<File>) Arrays.asList(files);
	}
}
 
开发者ID:BytingBulldogs3539,项目名称:BBLIB,代码行数:22,代码来源:Logger.java

示例6: findFile

import java.io.FilenameFilter; //导入依赖的package包/类
private List<File> findFile(File path, boolean isRecurse) {
    // 递归查找文件
    List<File> files = new ArrayList<File>();
    if (path.isDirectory()) {
        File[] candidates = path.listFiles(new FilenameFilter() {
            public boolean accept(File dir, String name) {
                if(name.endsWith(".swp")||name.endsWith(fileSuffix)||ignorePattern.matcher(name).matches()){
                    return false;
                }
                return true;
            }
        });
        for (int i = 0; i < candidates.length; i++) {
            if (candidates[i].isDirectory() && isRecurse) {
                files.addAll(findFile(candidates[i], isRecurse));
            } else {
                files.add(candidates[i]);
            }
        }
    }
    return files;
}
 
开发者ID:Transwarp-DE,项目名称:Transwarp-Sample-Code,代码行数:23,代码来源:LocalFileSource.java

示例7: getInprogressFiles

import java.io.FilenameFilter; //导入依赖的package包/类
/**
 * Get a list of files which are under process
 * 
 * @return list of file which are currently being used by WAL writers
 */

public String[] getInprogressFiles() {
  if (!initialized) {
    return null;
  }
  String[] files = walDirectory.toFile().list(new FilenameFilter() {
    @Override
    public boolean accept(File dir, String name) {
      if (name.endsWith(WAL_INPROGRESS_SUFFIX))
        return true;
      return false;
    }
  });
  if (null != files && files.length > 0) {
    Arrays.sort(files, new WALFileComparator());
  }
  return files;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:WriteAheadLog.java

示例8: prepareVersions

import java.io.FilenameFilter; //导入依赖的package包/类
private List<File> prepareVersions (File file) throws Exception {
    List<File> revisionList = new LinkedList<File>();
    File dataDir = new File(getDataDir(), "versionscache");
    File[] revisions = dataDir.listFiles(new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {
            return name.startsWith("rev");
        }
    });
    for (File rev : revisions) {
        if (rev.isFile()) {
            revisionList.add(0, rev);
            Utils.copyStreamsCloseAll(new FileOutputStream(file), new FileInputStream(rev));
            commit(new File[] {file});
        }
    }
    return revisionList;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:HistoryTest.java

示例9: compress

import java.io.FilenameFilter; //导入依赖的package包/类
/**
 * Compress.
 *
 * @param filename
 *            the filename
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
private void compress(String filename) throws IOException {
	File current = new File(filename);
	File dir = new File(metricPath);
	FilenameFilter textFileFilter = (f, s) -> s.endsWith(".txt");
	File[] directoryListing = dir.listFiles(textFileFilter);
	if (directoryListing != null) {
		for (File file : directoryListing) {
			if (file.getCanonicalPath() != current.getCanonicalPath()) {
				try (FileOutputStream fos = new FileOutputStream(file.getPath() + ".gz");
						GZIPOutputStream gzos = new GZIPOutputStream(fos)) {
					byte[] buffer = new byte[8192];
					int length;
					try (FileInputStream fis = new FileInputStream(file.getPath())) {
						while ((length = fis.read(buffer)) > 0) {
							gzos.write(buffer, 0, length);
						}
					}
				}
				file.delete();
			}
		}
	} else {
		throw new IOException("Directory not listable: " + metricPath);
	}
}
 
开发者ID:mevdschee,项目名称:tqdev-metrics,代码行数:34,代码来源:InfluxDbFileReporter.java

示例10: initTasks

import java.io.FilenameFilter; //导入依赖的package包/类
/**
 * Initializes a list of {@link IEvaluationTask} represented in XML by
 * XSTream serialization. Uses passed directory or current of omitted.
 *
 * @param args
 */
public void initTasks(String[] args) {
    tasks = new ArrayList<File>();

    String evalDir = ".";
    if (args.length >= 1) {
        evalDir = args[0];
    }
    File x = new File(evalDir);
    FilenameFilter filter = new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.endsWith(".eval.xml");
        }
    };
    tasks.addAll(Arrays.asList(x.listFiles(filter)));
    if (args.length >= 2) {
        isResume = args[1].equals("--resume");
        if(!isResume) {
            label = args[1];
        } else if(args.length >= 3) {
            label = args[2];
        }
    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:30,代码来源:ServerRunner.java

示例11: listFilesInDirWithFilter

import java.io.FilenameFilter; //导入依赖的package包/类
/**
 * 获取目录下所有符合filter的文件
 *
 * @param dir 目录
 * @param filter 过滤器
 * @param isRecursive 是否递归进子目录
 * @return 文件链表
 */
public static List<File> listFilesInDirWithFilter(File dir, FilenameFilter filter, boolean isRecursive) {
    if (isRecursive) {
        return listFilesInDirWithFilter(dir, filter);
    }
    if (dir == null || !isDir(dir)) {
        return null;
    }
    List<File> list = new ArrayList<>();
    File[] files = dir.listFiles();
    if (files != null && files.length != 0) {
        for (File file : files) {
            if (filter.accept(file.getParentFile(), file.getName())) {
                list.add(file);
            }
        }
    }
    return list;
}
 
开发者ID:imliujun,项目名称:LJFramework,代码行数:27,代码来源:FileUtils.java

示例12: getFilesByExt

import java.io.FilenameFilter; //导入依赖的package包/类
/**
 * Return all files with a given extension in a dir
 * @deprecated Is used only by deprecated method
 */
@Deprecated
public static String[] getFilesByExt(String ld, String ext) {
    File dir = new File(ld);
    String[] names = null;
    final String lext = ext;
    if (dir.isDirectory()) {
        names = dir.list(new FilenameFilter() {
            @Override
            public boolean accept(File d, String name) {
                if (name.endsWith(lext)) {
                    return true;
                }
                return false;
            }
        });
    }
    return names;
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:23,代码来源:IntrospectionUtils.java

示例13: searchFiles

import java.io.FilenameFilter; //导入依赖的package包/类
private static List<File> searchFiles(File dir, FilenameFilter filter) {
    List<File> result = new ArrayList<File>();
    File[] filesFiltered = dir.listFiles(filter), filesAll = dir.listFiles();

    if (filesFiltered != null) {
        result.addAll(Arrays.asList(filesFiltered));
    }

    if (filesAll != null) {
        for (File file : filesAll) {
            if (file.isDirectory()) {
                List<File> deeperList = searchFiles(file, filter);
                result.addAll(deeperList);
            }
        }
    }
    return result;
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:19,代码来源:FileUtils.java

示例14: findFile

import java.io.FilenameFilter; //导入依赖的package包/类
private static String findFile(String[] likelyPlaces, final String namePattern) {
    String path = null;
    for (String likelyPlace : likelyPlaces) {
        File[] f = new File(likelyPlace).listFiles(new FilenameFilter() {
            @Override public boolean accept(File dir, String name) {
                return name.matches(namePattern);
            }
        });
        if (f != null && f.length == 1) {
            try {
                path = f[0].getCanonicalPath();
                break;
            } catch (IOException e) {
            }
        }
    }
    ;
    return path;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:JavaProfile.java

示例15: listFilesInDirWithFilter

import java.io.FilenameFilter; //导入依赖的package包/类
/**
 * 获取目录下所有符合filter的文件包括子目录
 *
 * @param dir    目录
 * @param filter 过滤器
 * @return 文件链表
 */
public static List<File> listFilesInDirWithFilter(File dir, FilenameFilter filter) {
    if (dir == null || !isDir(dir)) return null;
    List<File> list = new ArrayList<>();
    File[] files = dir.listFiles();
    if (files != null && files.length != 0) {
        for (File file : files) {
            if (filter.accept(file.getParentFile(), file.getName())) {
                list.add(file);
            }
            if (file.isDirectory()) {
                list.addAll(listFilesInDirWithFilter(file, filter));
            }
        }
    }
    return list;
}
 
开发者ID:penghongru,项目名称:Coder,代码行数:24,代码来源:FileUtils.java


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