• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NameFileComparator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: FileAlterationObserver

import org.apache.commons.io.comparator.NameFileComparator; //导入依赖的package包/类
/**
 * Construct an observer for the specified directory, file filter and
 * file comparator.
 *
 * @param rootEntry the root directory to observe
 * @param fileFilter The file filter or null if none
 * @param caseSensitivity  what case sensitivity to use comparing file names, null means system sensitive
 */
protected FileAlterationObserver(FileEntry rootEntry, FileFilter fileFilter, IOCase caseSensitivity) {
    if (rootEntry == null) {
        throw new IllegalArgumentException("Root entry is missing");
    }
    if (rootEntry.getFile() == null) {
        throw new IllegalArgumentException("Root directory is missing");
    }
    this.rootEntry = rootEntry;
    this.fileFilter = fileFilter;
    if (caseSensitivity == null || caseSensitivity.equals(IOCase.SYSTEM)) {
        this.comparator = NameFileComparator.NAME_SYSTEM_COMPARATOR;
    } else if (caseSensitivity.equals(IOCase.INSENSITIVE)) {
        this.comparator = NameFileComparator.NAME_INSENSITIVE_COMPARATOR;
    } else {
        this.comparator = NameFileComparator.NAME_COMPARATOR;
    }
}
 
开发者ID:fesch,项目名称:Moenagade,代码行数:26,代码来源:FileAlterationObserver.java


示例2: getRestorableRealmFiles

import org.apache.commons.io.comparator.NameFileComparator; //导入依赖的package包/类
/**
 * Gets a list of currently backed up Realm files, ordered newest to oldest.
 * @return List of Realm database files.
 */
@NonNull
public static synchronized File[] getRestorableRealmFiles() {
    if (isBackingUp || dbRestoreState != DBRestoreState.NOT) return FileUtils.EMPTY_FILE_ARRAY;

    // Get the DB backups directory. If it doesn't exist or isn't a directory, return the empty list.
    File dbBackupDir = getExtDir(BACKUP_PATH);
    if (!dbBackupDir.isDirectory()) return FileUtils.EMPTY_FILE_ARRAY;

    // Get all files whose extensions match our DB backup extension. Sort so that the order is newest to oldest.
    File[] restorableDbFiles = dbBackupDir.listFiles((dir, filename) -> {
        return filename.endsWith(DB_BACKUP_EXT);
    });
    Arrays.sort(restorableDbFiles, NameFileComparator.NAME_INSENSITIVE_REVERSE);

    return restorableDbFiles;
}
 
开发者ID:bkromhout,项目名称:Minerva,代码行数:21,代码来源:BackupUtils.java


示例3: FileAlterationObserver

import org.apache.commons.io.comparator.NameFileComparator; //导入依赖的package包/类
/**
 * Construct an observer for the specified directory, file filter and
 * file comparator.
 *
 * @param rootEntry the root directory to observe
 * @param fileFilter The file filter or null if none
 * @param caseSensitivity  what case sensitivity to use comparing file names, null means system sensitive
 */
protected FileAlterationObserver(final FileEntry rootEntry, final FileFilter fileFilter,
                                 final IOCase caseSensitivity) {
    if (rootEntry == null) {
        throw new IllegalArgumentException("Root entry is missing");
    }
    if (rootEntry.getFile() == null) {
        throw new IllegalArgumentException("Root directory is missing");
    }
    this.rootEntry = rootEntry;
    this.fileFilter = fileFilter;
    if (caseSensitivity == null || caseSensitivity.equals(IOCase.SYSTEM)) {
        this.comparator = NameFileComparator.NAME_SYSTEM_COMPARATOR;
    } else if (caseSensitivity.equals(IOCase.INSENSITIVE)) {
        this.comparator = NameFileComparator.NAME_INSENSITIVE_COMPARATOR;
    } else {
        this.comparator = NameFileComparator.NAME_COMPARATOR;
    }
}
 
开发者ID:PuppyRush,项目名称:WidgetStore,代码行数:27,代码来源:FileAlterationObserver.java


示例4: assertDirectoriesEquals

import org.apache.commons.io.comparator.NameFileComparator; //导入依赖的package包/类
private void assertDirectoriesEquals(File directory1, File directory2, boolean checkFileContents) {
	if (directory1.exists()) {
		assertTrue(String.format("%s exists but %s does not", directory1, directory2),
				directory2.exists());
	} else {
		assertFalse(String.format("%s does not exists but %s does", directory1, directory2),
				directory2.exists());
	}
	File[] directory1Files = directory1.listFiles();
	File[] directory2Files = directory2.listFiles();
	// assert directories contain same number of files
	assertEquals(String.format("%s has %s files but %s has %s files", directory1.getName(),
			directory1Files.length, directory2.getName(), directory2Files.length),
			directory1Files.length, directory2Files.length);
	// sort files in directory
	Arrays.sort(directory1Files, NameFileComparator.NAME_SYSTEM_COMPARATOR);
	Arrays.sort(directory2Files, NameFileComparator.NAME_SYSTEM_COMPARATOR);
	for (int i = 0; i < directory1Files.length; i++) {
		assertFilesEqual(directory1Files[i], directory2Files[i], checkFileContents);
	}
}
 
开发者ID:apache,项目名称:incubator-taverna-commandline,代码行数:22,代码来源:TavernaCommandLineTest.java


示例5: FileAlterationObserver

import org.apache.commons.io.comparator.NameFileComparator; //导入依赖的package包/类
/**
 * Construct an observer for the specified directory, file filter and
 * file comparator.
 *
 * @param rootEntry the root directory to observe
 * @param fileFilter The file filter or null if none
 * @param caseSensitivity  what case sensitivity to use comparing file names, null means system sensitive
 */
protected FileAlterationObserver(FileEntry rootEntry, FileFilter fileFilter, IOCase caseSensitivity, boolean circulate) {
    if (rootEntry == null) {
        throw new IllegalArgumentException("Root entry is missing");
    }
    if (rootEntry.getFile() == null) {
        throw new IllegalArgumentException("Root directory is missing");
    }
    this.rootEntry = rootEntry;
    this.fileFilter = fileFilter;
    this.circulate = circulate;
    if (caseSensitivity == null || caseSensitivity.equals(IOCase.SYSTEM)) {
        this.comparator = NameFileComparator.NAME_SYSTEM_COMPARATOR;
    } else if (caseSensitivity.equals(IOCase.INSENSITIVE)) {
        this.comparator = NameFileComparator.NAME_INSENSITIVE_COMPARATOR;
    } else {
        this.comparator = NameFileComparator.NAME_COMPARATOR;
    }
}
 
开发者ID:Jakegogo,项目名称:concurrent,代码行数:27,代码来源:FileAlterationObserver.java


示例6: convertSortOrder

import org.apache.commons.io.comparator.NameFileComparator; //导入依赖的package包/类
protected Comparator<File> convertSortOrder()
{
    Comparator<File> result = NameFileComparator.NAME_COMPARATOR;
    if ( getSortOrder().equalsIgnoreCase( "NAME_INSENSITIVE_COMPARATOR" ) )
    {
        result = NameFileComparator.NAME_INSENSITIVE_COMPARATOR;
    }
    else if ( getSortOrder().equalsIgnoreCase( "NAME_INSENSITIVE_REVERSE" ) )
    {
        result = NameFileComparator.NAME_INSENSITIVE_REVERSE;
    }
    else if ( getSortOrder().equalsIgnoreCase( "NAME_REVERSE" ) )
    {
        result = NameFileComparator.NAME_REVERSE;
    }
    else if ( getSortOrder().equalsIgnoreCase( "NAME_SYSTEM_COMPARATOR" ) )
    {
        result = NameFileComparator.NAME_SYSTEM_COMPARATOR;
    }
    else if ( getSortOrder().equalsIgnoreCase( "NAME_SYSTEM_REVERSE" ) )
    {
        result = NameFileComparator.NAME_SYSTEM_REVERSE;
    }
    return result;
}
 
开发者ID:khmarbaise,项目名称:iterator-maven-plugin,代码行数:26,代码来源:AbstractIteratorMojo.java


示例7: cleanDumpDatabase

import org.apache.commons.io.comparator.NameFileComparator; //导入依赖的package包/类
public void cleanDumpDatabase(int keepno)
{
   File[]dumps = new File(
         cfgManager.getDatabaseConfiguration ().getDumpPath ())
         .listFiles(new FilenameFilter()
   {
      @Override
      public boolean accept(File path, String name)
      {
         if (name.startsWith("dump-"))
            return true;
         return false;
      }
   });
   if ((dumps!=null) && (dumps.length > keepno))
   {
      Arrays.sort(dumps, NameFileComparator.NAME_COMPARATOR);
      int last = dumps.length - keepno;
      for (int index=0; index<last; index++)
      {
         File dir = dumps[index];
         try
         {
            Date date = new Date (Long.parseLong (dir.getName ()
                  .replaceAll ("dump-(.*)", "$1")));
            LOGGER.info("Cleaned dump of " + date);
            FileUtils.deleteDirectory(dir);
         }
         catch (IOException e)
         {
            LOGGER.warn("Cannot delete directory " + dir.getPath() + " (" +
               e.getMessage() + ")");
         }
      }
   }
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:37,代码来源:SystemService.java


示例8: getFilesItemsInCurrentDirectory

import org.apache.commons.io.comparator.NameFileComparator; //导入依赖的package包/类
public ArrayList<FileItem> getFilesItemsInCurrentDirectory() {
    Operations op = Operations.getInstance(mContext);
    Constants.SORT_OPTIONS option = op.getmCurrentSortOption();
    Constants.FILTER_OPTIONS filterOption = op.getmCurrentFilterOption();
    if (mFileNavigator.getmCurrentNode() == null) mFileNavigator.setmCurrentNode(mFileNavigator.getmRootNode());
    File[] files = mFileNavigator.getFilesInCurrentDirectory();
    if (files != null) {
        mFiles.clear();
        Comparator<File> comparator = NameFileComparator.NAME_INSENSITIVE_COMPARATOR;
        switch(option) {
            case SIZE:
                comparator = SizeFileComparator.SIZE_COMPARATOR;
                break;
            case LAST_MODIFIED:
                comparator = LastModifiedFileComparator.LASTMODIFIED_COMPARATOR;
                break;
        }
        Arrays.sort(files,comparator);
        for (int i = 0; i < files.length; i++) {
            boolean addToFilter = true;
            switch(filterOption) {
                case FILES:
                    addToFilter = !files[i].isDirectory();
                    break;
                case FOLDER:
                    addToFilter = files[i].isDirectory();
                    break;
            }
            if (addToFilter)
                mFiles.add(new FileItem(files[i]));
        }
    }
    return mFiles;
}
 
开发者ID:adityak368,项目名称:Android-FileBrowser-FilePicker,代码行数:35,代码来源:NavigationHelper.java


示例9: getLogNames

import org.apache.commons.io.comparator.NameFileComparator; //导入依赖的package包/类
public List<String> getLogNames() {
    List<String> names = new ArrayList<>();
    File[] files = this.activityDir.listFiles();
    if (files != null) {
        Arrays.sort(files, NameFileComparator.NAME_REVERSE);
        for (File file : files) {
            names.add(file.getName());
        }
    }
    return names;
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:12,代码来源:SQSActivityAction.java


示例10: toTemplates

import org.apache.commons.io.comparator.NameFileComparator; //导入依赖的package包/类
private TemplateFile[] toTemplates(File dir, String parentPath) {
	List<TemplateFile> list = new ArrayList<>();
	File[] files = dir.listFiles();

	Arrays.sort(files, NameFileComparator.NAME_COMPARATOR);
	Arrays.sort(files, DirectoryFileComparator.DIRECTORY_COMPARATOR);

	for (File file : files) {
		TemplateFile templateFile = new TemplateFile();
		templateFile.setText(file.getName());
		String path = parentPath + "/" + file.getName();
		templateFile.setPath(path);
		if (file.isDirectory()) {
			templateFile.setChildren(toTemplates(file, path));
			templateFile.setIconCls("Folder");
		} else {
			String extension = FilenameUtils.getExtension(file.getName());
			if ("html".equals(extension)) {
				templateFile.setIconCls("Html");
			} else if ("js".equals(extension)) {
				templateFile.setIconCls("Script");
			} else if ("css".equals(extension)) {
				templateFile.setIconCls("Css");
			} else {
				templateFile.setIconCls("Page");
			}
		}
		list.add(templateFile);
	}

	return Iterables.toArray(list, TemplateFile.class);
}
 
开发者ID:xiangxik,项目名称:java-platform,代码行数:33,代码来源:TemplateService.java


示例11: assertOutputsEquals

import org.apache.commons.io.comparator.NameFileComparator; //导入依赖的package包/类
private void assertOutputsEquals(File directory1, File directory2) {
	File[] directory1Files = directory1.listFiles();
	File[] directory2Files = directory2.listFiles();
	// assert directories contain same number of files
	assertEquals(String.format("%s has %s files but %s has %s files", directory1.getName(),
			directory1Files.length, directory2.getName(), directory2Files.length),
			directory1Files.length, directory2Files.length);
	// sort files in directory
	Arrays.sort(directory1Files, NameFileComparator.NAME_SYSTEM_COMPARATOR);
	Arrays.sort(directory2Files, NameFileComparator.NAME_SYSTEM_COMPARATOR);
	for (int i = 0; i < directory1Files.length; i++) {
		assertFilesEqual(directory1Files[i], directory2Files[i], !directory1Files[i].getName()
				.equals(ignorePort));
	}
}
 
开发者ID:apache,项目名称:incubator-taverna-commandline,代码行数:16,代码来源:TavernaCommandLineTest.java


示例12: getFilesByExtension

import org.apache.commons.io.comparator.NameFileComparator; //导入依赖的package包/类
public static File[] getFilesByExtension(String path, final String extension) throws IllegalArgumentException {
	File pathHandle = new File(path);
	
	if (pathHandle.exists()) {
		if (pathHandle.isDirectory()) {
			File[] searchResults = pathHandle.listFiles(new FilenameFilter() {
	            public boolean accept(File folder, String name) {
	            	if (name.toLowerCase().endsWith("." + extension)) {
	            		return true;
	            	} else {
	            		return false;
	            	}
	            }
	        });
			
			if (searchResults.length > 0) {
				// Sort files by name (Required to load files in a desired order
				Arrays.sort(searchResults, NameFileComparator.NAME_INSENSITIVE_COMPARATOR);
			}
			
			return searchResults;
		} else {
			throw new IllegalArgumentException("The given directory path '" + pathHandle.getAbsolutePath() + "' is not a directory.");
		}
	} else {
		throw new IllegalArgumentException("The given directory path '" + pathHandle.getAbsolutePath() + "' does not exist.");
	}
}
 
开发者ID:ssmits,项目名称:HBM,代码行数:29,代码来源:HbmFileSystemUtil.java


示例13: open

import org.apache.commons.io.comparator.NameFileComparator; //导入依赖的package包/类
@Override
public void open(ExecutionContext executionContext)	throws ItemStreamException {
	File directory = new File(directoryName);
	if(directory.isDirectory()) {
		this.files = directory.listFiles((FileFilter) FileFilterUtils.fileFileFilter());
		if(files.length > 1) {
			Arrays.sort(files, new NameFileComparator());
		}
	} else {
		throw new IllegalArgumentException(directoryName + " is not a directory");
	}
	currentCount = executionContext.getInt(key, 0);
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:14,代码来源:DirectoryReader.java


示例14: execute

import org.apache.commons.io.comparator.NameFileComparator; //导入依赖的package包/类
/**
 * Called by Maven to run this mojo after parameters have been injected.
 */
public void execute() throws MojoExecutionException {

    if (!featuresDirectory.exists()) {
        throw new MojoExecutionException("Features directory does not exist");
    }

    final Collection<File> featureFiles = listFiles(featuresDirectory, new String[] {"feature"}, true);
    final List<File> sortedFeatureFiles = new NameFileComparator().sort(new ArrayList<File>(featureFiles));

    createOutputDirIfRequired();

    File packageDirectory = packageName == null
            ? outputDirectory
            : new File(outputDirectory, packageName.replace('.','/'));

    if (!packageDirectory.exists()) {
        packageDirectory.mkdirs();
    }

    final CucumberITGenerator fileGenerator = createFileGenerator();
    fileGenerator.generateCucumberITFiles(packageDirectory, sortedFeatureFiles);

    getLog().info("Adding " + outputDirectory.getAbsolutePath()
                    + " to test-compile source root");

    project.addTestCompileSourceRoot(outputDirectory.getAbsolutePath());
}
 
开发者ID:temyers,项目名称:cucumber-jvm-parallel-plugin,代码行数:31,代码来源:GenerateRunnersMojo.java


示例15: setDirectory

import org.apache.commons.io.comparator.NameFileComparator; //导入依赖的package包/类
public void setDirectory(String directory) {
    this.files = new File(directory).listFiles((FileFilter) FileFilterUtils.fileFileFilter());
    Arrays.sort(files, new NameFileComparator());
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:5,代码来源:FilesInDirectoryItemReader.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InvokeMethod类代码示例发布时间:2022-05-21
下一篇:
Java Repeat类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap