本文整理了Java中java.io.FileFilter.accept()
方法的一些代码示例,展示了FileFilter.accept()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileFilter.accept()
方法的具体详情如下:
包路径:java.io.FileFilter
类名称:FileFilter
方法名:accept
[英]Indicating whether a specific file should be included in a pathname list.
[中]指示是否应将特定文件包括在路径名列表中。
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Checks whether a file satisfies the selection filter.
*
* @param file The file
* @return true if the file is acceptable
*/
public boolean accept(File file) {
return f1.accept(file) && f2.accept(file);
}
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Checks whether a file satisfies the selection filter.
*
* @param file The file
* @return true if the file is acceptable
*/
public boolean accept(File file) {
return ! f1.accept(file);
}
代码示例来源:origin: redisson/redisson
public static boolean isFilePathAcceptable(File file, FileFilter fileFilter) {
do {
if (fileFilter != null && !fileFilter.accept(file)) {
return false;
}
file = file.getParentFile();
} while (file != null);
return true;
}
代码示例来源:origin: hawtio/hawtio
@Override
public boolean accept(File file) {
return filter1.accept(file) && filter2.accept(file);
}
};
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
@Override
public boolean accept(File pathname) {
return filter == null || filter.accept(pathname);
}
代码示例来源:origin: oblac/jodd
/**
* Checks if file and its ancestors are acceptable by using {@link FileFilter#accept(File)}.
*
* @param file {@link File} to check.
* @param fileFilter {@link FileFilter} to use.
* @return if file and its ancestors are acceptable
*/
public static boolean isFilePathAcceptable(File file, final FileFilter fileFilter) {
do {
if (fileFilter != null && !fileFilter.accept(file)) {
return false;
}
file = file.getParentFile();
} while (file != null);
return true;
}
代码示例来源:origin: jenkinsci/jenkins
public void visit(File f, String relativePath) throws IOException {
if(f.isDirectory() || filter.accept(f))
visitor.visit(f,relativePath);
}
代码示例来源:origin: commons-io/commons-io
/**
* Checks the filter.
*
* @param file the file to check
* @return true if the filter matches
*/
@Override
public boolean accept(final File file) {
if (fileFilter != null) {
return fileFilter.accept(file);
} else {
return super.accept(file);
}
}
代码示例来源:origin: neo4j/neo4j
void addFile( File file )
{
if ( canBeManagedByPageCache( file ) || mappedIndexFilter.accept( file ) )
{
size += file.length();
}
}
代码示例来源:origin: org.apache.commons/commons-io
/**
* Checks the filter.
*
* @param file the file to check
* @return true if the filter matches
*/
public boolean accept(File file) {
if (fileFilter != null) {
return fileFilter.accept(file);
} else {
return super.accept(file);
}
}
代码示例来源:origin: libgdx/libgdx
public FileHandle[] list (String url, FileFilter filter) {
Array<FileHandle> files = new Array<FileHandle>();
for (String path : texts.keys()) {
if (isChild(path, url) && filter.accept(new File(path))) {
files.add(new GwtFileHandle(this, path, FileType.Internal));
}
}
FileHandle[] list = new FileHandle[files.size];
System.arraycopy(files.items, 0, list, 0, list.length);
return list;
}
代码示例来源:origin: libgdx/libgdx
public FileHandle[] list (String url, FileFilter filter) {
Array<FileHandle> files = new Array<FileHandle>();
for (String path : texts.keys()) {
if (isChild(path, url) && filter.accept(new File(path))) {
files.add(new GwtFileHandle(this, path, FileType.Internal));
}
}
FileHandle[] list = new FileHandle[files.size];
System.arraycopy(files.items, 0, list, 0, list.length);
return list;
}
代码示例来源:origin: libgdx/libgdx
public FileHandle[] list (FileFilter filter) {
if (type == FileType.Internal) {
try {
String[] relativePaths = assets.list(file.getPath());
FileHandle[] handles = new FileHandle[relativePaths.length];
int count = 0;
for (int i = 0, n = handles.length; i < n; i++) {
String path = relativePaths[i];
FileHandle child = new AndroidFileHandle(assets, new File(file, path), type);
if (!filter.accept(child.file())) continue;
handles[count] = child;
count++;
}
if (count < relativePaths.length) {
FileHandle[] newHandles = new FileHandle[count];
System.arraycopy(handles, 0, newHandles, 0, count);
handles = newHandles;
}
return handles;
} catch (Exception ex) {
throw new GdxRuntimeException("Error listing children: " + file + " (" + type + ")", ex);
}
}
return super.list(filter);
}
代码示例来源:origin: neo4j/neo4j
private FilenameFilter getNativeIndexFileFilter( File storeDir, boolean inverse )
{
FileFilter nativeIndexFilter = new NativeIndexFileFilter( storeDir );
return ( dir, name ) ->
{
File file = new File( dir, name );
if ( outsideWorld.fileSystem().isDirectory( file ) )
{
// Always go down directories
return true;
}
if ( name.equals( FailureStorage.DEFAULT_FAILURE_FILE_NAME ) )
{
// Never include failure-storage files
return false;
}
return inverse != nativeIndexFilter.accept( file );
};
}
代码示例来源:origin: libgdx/libgdx
public FileHandle[] list (FileFilter filter) {
if (type == FileType.Internal) {
try {
String[] relativePaths = assets.list(file.getPath());
FileHandle[] handles = new FileHandle[relativePaths.length];
int count = 0;
for (int i = 0, n = handles.length; i < n; i++) {
String path = relativePaths[i];
FileHandle child = new AndroidFileHandle(assets, new File(file, path), type);
if (!filter.accept(child.file())) continue;
handles[count] = child;
count++;
}
if (count < relativePaths.length) {
FileHandle[] newHandles = new FileHandle[count];
System.arraycopy(handles, 0, newHandles, 0, count);
handles = newHandles;
}
return handles;
} catch (Exception ex) {
throw new GdxRuntimeException("Error listing children: " + file + " (" + type + ")", ex);
}
}
return super.list(filter);
}
代码示例来源:origin: libgdx/libgdx
/** Returns the paths to the children of this directory that satisfy the specified filter. Returns an empty list if this file
* handle represents a file and not a directory. On the desktop, an {@link FileType#Internal} handle to a directory on the
* classpath will return a zero length array.
* @param filter the {@link FileFilter} to filter files
* @throws GdxRuntimeException if this file is an {@link FileType#Classpath} file. */
public FileHandle[] list (FileFilter filter) {
if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot list a classpath directory: " + file);
File file = file();
String[] relativePaths = file.list();
if (relativePaths == null) return new FileHandle[0];
FileHandle[] handles = new FileHandle[relativePaths.length];
int count = 0;
for (int i = 0, n = relativePaths.length; i < n; i++) {
String path = relativePaths[i];
FileHandle child = child(path);
if (!filter.accept(child.file())) continue;
handles[count] = child;
count++;
}
if (count < relativePaths.length) {
FileHandle[] newHandles = new FileHandle[count];
System.arraycopy(handles, 0, newHandles, 0, count);
handles = newHandles;
}
return handles;
}
代码示例来源:origin: libgdx/libgdx
@Override
public FileHandle[] list(FileFilter filter) {
ZipEntryRO[] zipEntries = expansionFile.getEntriesAt(getPath());
FileHandle[] handles = new FileHandle[zipEntries.length];
int count = 0;
for (int i = 0, n = handles.length; i < n; i++) {
FileHandle child = new AndroidZipFileHandle(zipEntries[i].mFileName);
if (!filter.accept(child.file()))
continue;
handles[count] = child;
count++;
}
if (count < zipEntries.length) {
FileHandle[] newHandles = new FileHandle[count];
System.arraycopy(handles, 0, newHandles, 0, count);
handles = newHandles;
}
return handles;
}
代码示例来源:origin: libgdx/libgdx
/** Returns the paths to the children of this directory that satisfy the specified filter. Returns an empty list if this file
* handle represents a file and not a directory. On the desktop, an {@link FileType#Internal} handle to a directory on the
* classpath will return a zero length array.
* @param filter the {@link FileFilter} to filter files
* @throws GdxRuntimeException if this file is an {@link FileType#Classpath} file. */
public FileHandle[] list (FileFilter filter) {
if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot list a classpath directory: " + file);
File file = file();
String[] relativePaths = file.list();
if (relativePaths == null) return new FileHandle[0];
FileHandle[] handles = new FileHandle[relativePaths.length];
int count = 0;
for (int i = 0, n = relativePaths.length; i < n; i++) {
String path = relativePaths[i];
FileHandle child = child(path);
if (!filter.accept(child.file())) continue;
handles[count] = child;
count++;
}
if (count < relativePaths.length) {
FileHandle[] newHandles = new FileHandle[count];
System.arraycopy(handles, 0, newHandles, 0, count);
handles = newHandles;
}
return handles;
}
代码示例来源:origin: libgdx/libgdx
@Override
public FileHandle[] list(FileFilter filter) {
ZipEntryRO[] zipEntries = expansionFile.getEntriesAt(getPath());
FileHandle[] handles = new FileHandle[zipEntries.length];
int count = 0;
for (int i = 0, n = handles.length; i < n; i++) {
FileHandle child = new AndroidZipFileHandle(zipEntries[i].mFileName);
if (!filter.accept(child.file()))
continue;
handles[count] = child;
count++;
}
if (count < zipEntries.length) {
FileHandle[] newHandles = new FileHandle[count];
System.arraycopy(handles, 0, newHandles, 0, count);
handles = newHandles;
}
return handles;
}
代码示例来源:origin: syncany/syncany
public static Map<String, File> getLocalFiles(File root, FileFilter filter) throws FileNotFoundException {
List<File> fileList = getRecursiveFileList(root, true, false);
Map<String, File> fileMap = new HashMap<String, File>();
for (File file : fileList) {
if (filter != null && !filter.accept(file)) {
continue;
}
String relativePath = FileUtil.getRelativePath(root, file);
if (relativePath.startsWith(IGNORE_DIR_APPLICATION)) {
continue;
}
fileMap.put(relativePath, file);
}
return fileMap;
}
内容来源于网络,如有侵权,请联系作者删除!