本文整理汇总了Java中org.apache.commons.io.filefilter.DirectoryFileFilter.DIRECTORY属性的典型用法代码示例。如果您正苦于以下问题:Java DirectoryFileFilter.DIRECTORY属性的具体用法?Java DirectoryFileFilter.DIRECTORY怎么用?Java DirectoryFileFilter.DIRECTORY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.io.filefilter.DirectoryFileFilter
的用法示例。
在下文中一共展示了DirectoryFileFilter.DIRECTORY属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listFilesOrDirectories
/**
* get the list of files or directories in a directory
*
* @param pathname
* the directory pathname to list
* @param type
* the type of File list to return: LIST_FILES_ONLY or
* LIST_DIRECTORIES_ONLY
* @return the files or directories list
*
* @throws InvalidLoginException
*/
private List<String> listFilesOrDirectories(String pathname, int type)
throws InvalidLoginException {
pathname = PathUtil.rewriteToUnixSyntax(pathname);
RemoteFile theRemoteFile = new RemoteFile(remoteSession, pathname);
FileFilter fileFilter = null;
if (type == LIST_FILES_ONLY) {
fileFilter = FileFileFilter.FILE;
} else if (type == LIST_DIRECTORIES_ONLY) {
fileFilter = DirectoryFileFilter.DIRECTORY;
} else {
throw new IllegalArgumentException(
Tag.PRODUCT_PRODUCT_FAIL
+ " Invalid type. Msust be LIST_FILES_ONLY or LIST_DIRECTORIES_ONLY. Is: "
+ type);
}
RemoteFile[] remoteFiles = theRemoteFile.listFiles(fileFilter);
if (remoteFiles == null) {
return null;
}
List<String> filenameList = new ArrayList<String>();
for (RemoteFile remoteFileItem : remoteFiles) {
filenameList.add(remoteFileItem.getName());
}
return filenameList;
}
示例2: loadSetFromDirectory
private void loadSetFromDirectory(File directory, Set<String> sessionIds, int depth)
{
if (depth < MAX_DPETH)
{
FileFilter filter = (FileFilter) DirectoryFileFilter.DIRECTORY;
File[] subdirectories = directory.listFiles(filter);
for (File subdirectory : subdirectories)
{
this.loadSetFromDirectory(subdirectory, sessionIds, ( depth + 1 ));
}
}
else
{
File[] sessions = directory.listFiles();
for (File session : sessions)
{
if (session.isFile())
{
String sessionId = session.getName();
sessionIds.add(sessionId);
}
else
{
throw new ProgrammingErrorException("Expecting only session");
}
}
}
}
示例3: SubDirectoryWalker
public SubDirectoryWalker(List<KeyValue> keyValues) {
super(DirectoryFileFilter.DIRECTORY, -1);
this.keyValues = keyValues;
this.recursiveDepth = 0;
}