本文整理汇总了Java中org.apache.commons.io.filefilter.PrefixFileFilter类的典型用法代码示例。如果您正苦于以下问题:Java PrefixFileFilter类的具体用法?Java PrefixFileFilter怎么用?Java PrefixFileFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrefixFileFilter类属于org.apache.commons.io.filefilter包,在下文中一共展示了PrefixFileFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DefaultCommandStore
import org.apache.commons.io.filefilter.PrefixFileFilter; //导入依赖的package包/类
public DefaultCommandStore(File file, int maxFileSize, int minTimeMilliToGcAfterModified, int fileNumToKeep, KeeperMonitor keeperMonitor) throws IOException {
this.baseDir = file.getParentFile();
this.fileNamePrefix = file.getName();
this.maxFileSize = maxFileSize;
this.fileNumToKeep = fileNumToKeep;
this.minTimeMilliToGcAfterModified = minTimeMilliToGcAfterModified;
this.commandStoreDelay = keeperMonitor.createCommandStoreDelay(this);
fileFilter = new PrefixFileFilter(fileNamePrefix);
long currentStartOffset = findMaxStartOffset();
File currentFile = fileForStartOffset(currentStartOffset);
logger.info("Write to {}", currentFile.getName());
CommandFileContext cmdFileCtx = new CommandFileContext(currentStartOffset, currentFile);
cmdFileCtxRef.set(cmdFileCtx);
offsetNotifier = new OffsetNotifier(cmdFileCtx.totalLength() - 1);
}
示例2: scanDir
import org.apache.commons.io.filefilter.PrefixFileFilter; //导入依赖的package包/类
/**
* Scan a directory for packages that match. This method is used prior to
* finding a matching directory. Once the package names is matched
* handleDir() is used.
*
* @param classes
* The classes that have been found.
* @param packageName
* The package name for classes to find.
* @param dir
* The directory to scan.
* @param cFilter
* The class acceptance filter.
*/
private static void scanDir(Set<String> classes, String packageName, File dir, ClassPathFilter cFilter) {
if (!dir.exists()) {
return;
}
if (dir.isDirectory()) {
if (dir.getPath().endsWith(packageName.replace('.', '/'))) {
// we have a match
handleDir(classes, packageName, dir, cFilter);
} else {
// no match check next level
for (File file : dir.listFiles((FileFilter) new AndFileFilter(DirectoryFileFilter.DIRECTORY,
new NotFileFilter(new PrefixFileFilter("."))))) {
scanDir(classes, packageName, file, cFilter);
}
}
}
// if it is not a directory we don't process it here as we are looking
// for directories that start with the packageName.
}
示例3: extractFileUserIdentifiers
import org.apache.commons.io.filefilter.PrefixFileFilter; //导入依赖的package包/类
/**
* Return set of file user identifiers from a list of files
*
* @param user user who uploaded or will upload file
* @param files list of files objects
* @return Set containing all user identifiers from list of files
*
* @see org.kuali.kfs.sys.batch.BatchInputFileSetType#extractFileUserIdentifiers(org.kuali.rice.kim.api.identity.Person, java.util.List)
*/
public Set<String> extractFileUserIdentifiers(Person user, List<File> files) {
Set<String> extractedFileUserIdentifiers = new TreeSet<String>();
StringBuilder buf = new StringBuilder();
buf.append(FILE_NAME_PREFIX).append(FILE_NAME_PART_DELIMITER).append(user.getPrincipalName()).append(FILE_NAME_PART_DELIMITER);
String prefixString = buf.toString();
IOFileFilter prefixFilter = new PrefixFileFilter(prefixString);
IOFileFilter suffixFilter = new SuffixFileFilter(CamsConstants.BarCodeInventory.DATA_FILE_EXTENSION);
IOFileFilter combinedFilter = new AndFileFilter(prefixFilter, suffixFilter);
for (File file : files) {
if (combinedFilter.accept(file)) {
String fileName = file.getName();
if (fileName.endsWith(CamsConstants.BarCodeInventory.DATA_FILE_EXTENSION)) {
extractedFileUserIdentifiers.add(StringUtils.substringBetween(fileName, prefixString, CamsConstants.BarCodeInventory.DATA_FILE_EXTENSION));
} else {
LOG.error("Unable to determine file user identifier for file name: " + fileName);
throw new RuntimeException("Unable to determine file user identifier for file name: " + fileName);
}
}
}
return extractedFileUserIdentifiers;
}
示例4: importOrganizations
import org.apache.commons.io.filefilter.PrefixFileFilter; //导入依赖的package包/类
/** Import organizations */
private void importOrganizations() throws Exception {
String[] organizationFileNames = importDir.list( new PrefixFileFilter( "organization." ) );
logger.info( "Organizations to read: " + organizationFileNames.length );
for ( String organizationFileName : organizationFileNames ) {
try {
importOrganization( organizationFileName );
}
catch ( Exception e ) {
logger.warn( "Unable to import organization:" + organizationFileName, e );
}
}
}
示例5: isTranscodingStepInstalled
import org.apache.commons.io.filefilter.PrefixFileFilter; //导入依赖的package包/类
private boolean isTranscodingStepInstalled(String step) {
if (StringUtils.isEmpty(step)) {
return true;
}
String executable = StringUtil.split(step)[0];
PrefixFileFilter filter = new PrefixFileFilter(executable);
String[] matches = getTranscodeDirectory().list(filter);
return matches != null && matches.length > 0;
}
示例6: getFilenames
import org.apache.commons.io.filefilter.PrefixFileFilter; //导入依赖的package包/类
public static List<String> getFilenames(String playerName)
{
checkFilePath();
File file = new File(TombManyGraves.file + FILE_PREFIX);
String[] fileNames = file.list(new PrefixFileFilter(playerName));
for (int i=0; i < fileNames.length; i++)
{
fileNames[i] = fileNames[i].substring(fileNames[i].indexOf("#")+1,fileNames[i].indexOf(".json"));
}
return Arrays.asList(fileNames);
}
示例7: clear
import org.apache.commons.io.filefilter.PrefixFileFilter; //导入依赖的package包/类
public void clear()
{
File deployFolder = deployableFile.getParentFile();
if (!deployFolder.exists())
{
return;
}
PrefixFileFilter optionsFileFilter = new PrefixFileFilter(getTargetFilePrefix());
Collection<File> targetOptionsFiles = FileUtils.listFiles(deployFolder, optionsFileFilter, null);
for (File targetOptionFile : targetOptionsFiles)
{
FileUtils.deleteQuietly(targetOptionFile);
}
}
示例8: addSources
import org.apache.commons.io.filefilter.PrefixFileFilter; //导入依赖的package包/类
private void addSources(ProjectDefinition project) {
final File basedir = project.getBaseDir();
logger.debug(basedir.getAbsolutePath());
// TODO: ignore child modules folders more properly
IOFileFilter custom = new IOFileFilter() {
@Override
public boolean accept(File file) {
return file.isDirectory()
&& !(new File(file, "pom.xml").exists())
|| file.getAbsolutePath().equals(
basedir.getAbsolutePath());
}
@Override
public boolean accept(File dir, String name) {
return false;
}
};
Collection<File> files = FileUtils.listFiles(basedir,
new SuffixFileFilter(".process"), new AndFileFilter(
new NotFileFilter(new PrefixFileFilter("target")),
custom));
project.addSources(files.toArray(new File[0]));
}
示例9: reconstructLineBased
import org.apache.commons.io.filefilter.PrefixFileFilter; //导入依赖的package包/类
public static void reconstructLineBased(File partFolder,
File reconstructed, boolean removeHeaders) throws IOException {
Path tmpOut = Files.createTempFile(partFolder.toPath(), "reconstr",
".tmp");
BufferedOutputStream dstOut = new BufferedOutputStream(
new FileOutputStream(tmpOut.toFile()));
try {
if (!Files.isDirectory(partFolder.toPath()))
throw new IOException("Not a directory: " + partFolder);
File[] fileList = FileUtils.listFiles(partFolder,
new PrefixFileFilter("part"), TrueFileFilter.TRUE).toArray(
new File[0]);
Arrays.sort(fileList);
for (int i = 0; i < fileList.length; i++) {
if (fileList[i].canRead()) {
BufferedReader in = new BufferedReader(new FileReader(
fileList[i]));
try {
if (removeHeaders && i != 0)
in.readLine();
IOUtils.copy(in, dstOut);
} finally {
in.close();
}
}
}
} finally {
dstOut.close();
}
Files.move(tmpOut, reconstructed.toPath(),
StandardCopyOption.ATOMIC_MOVE,
StandardCopyOption.REPLACE_EXISTING);
FileUtils.deleteQuietly(tmpOut.toFile());
FileUtils.deleteQuietly(partFolder);
}
示例10: reconstructTurtle
import org.apache.commons.io.filefilter.PrefixFileFilter; //导入依赖的package包/类
public static void reconstructTurtle(File partFolder, File reconstructed)
throws IOException {
Path tmpOut = Files.createTempFile(partFolder.toPath(), "reconstr",
".tmp");
FileOutputStream dstOut = new FileOutputStream(tmpOut.toFile());
FileChannel dstOutChannel = dstOut.getChannel();
try {
if (!Files.isDirectory(partFolder.toPath()))
throw new IOException("Not a directory: " + partFolder);
File[] fileList = FileUtils.listFiles(partFolder,
new PrefixFileFilter("part"), TrueFileFilter.TRUE).toArray(
new File[0]);
Arrays.sort(fileList);
RandomAccessFile inputFile;
inputFile = new RandomAccessFile(fileList[0], "r");
inputFile.getChannel().transferTo(0, inputFile.length(),
dstOutChannel);
inputFile.close();
for (int i = 1; i < fileList.length; i++) {
inputFile = new RandomAccessFile(fileList[i], "r");
long lastPrefix = findTurtlePrefixEnd(inputFile);
inputFile.getChannel().transferTo(lastPrefix,
inputFile.length() - lastPrefix, dstOutChannel);
inputFile.close();
}
} finally {
dstOut.close();
}
Files.move(tmpOut, reconstructed.toPath(),
StandardCopyOption.ATOMIC_MOVE,
StandardCopyOption.REPLACE_EXISTING);
FileUtils.deleteQuietly(tmpOut.toFile());
FileUtils.deleteQuietly(partFolder);
}
示例11: reconstructLineBased
import org.apache.commons.io.filefilter.PrefixFileFilter; //导入依赖的package包/类
/**
* Method that to reconstruct part* files into a single file <BR>
* Suitable for line-based, CSV files.
*
* @param partFolder
* directory contatining partial files (part001,part002..)
* @param reconstructed
* file to which the output is written
* @throws IOException
*/
public static void reconstructLineBased(File partFolder,
File reconstructed, boolean removeHeaders) throws IOException {
Path tmpOut = Files.createTempFile(partFolder.toPath(), "reconstr",
".tmp");
BufferedOutputStream dstOut = new BufferedOutputStream(
new FileOutputStream(tmpOut.toFile()));
try {
if (!Files.isDirectory(partFolder.toPath()))
throw new IOException("Not a directory: " + partFolder);
File[] fileList = FileUtils.listFiles(partFolder,
new PrefixFileFilter("part"), TrueFileFilter.TRUE).toArray(
new File[0]);
Arrays.sort(fileList);
for (int i = 0; i < fileList.length; i++) {
if (fileList[i].canRead()) {
BufferedReader in = new BufferedReader(new FileReader(
fileList[i]));
try {
if (removeHeaders && i != 0)
in.readLine();
IOUtils.copy(in, dstOut);
} finally {
in.close();
}
}
}
} finally {
dstOut.close();
}
Files.move(tmpOut, reconstructed.toPath(),
StandardCopyOption.ATOMIC_MOVE,
StandardCopyOption.REPLACE_EXISTING);
FileUtils.deleteQuietly(tmpOut.toFile());
FileUtils.deleteQuietly(partFolder);
}
示例12: retrieveFilesToAggregate
import org.apache.commons.io.filefilter.PrefixFileFilter; //导入依赖的package包/类
protected List<File> retrieveFilesToAggregate() {
File inputDirectory = new File(inputFilePath);
if (!inputDirectory.exists() || !inputDirectory.isDirectory()) {
throw new RuntimeException(inputFilePath + " does not exist or is not a directory.");
}
FileFilter filter = FileFilterUtils.andFileFilter(
new PrefixFileFilter(inputFilePrefix), new SuffixFileFilter(inputFileSuffix));
List<File> fileList = Arrays.asList(inputDirectory.listFiles(filter));
Collections.sort(fileList);
return fileList;
}
示例13: extractFileUserIdentifiers
import org.apache.commons.io.filefilter.PrefixFileFilter; //导入依赖的package包/类
/**
* Return set of file user identifiers from a list of files
*
* @param user user who uploaded or will upload file
* @param files list of files objects
* @return Set containing all user identifiers from list of files
* @see org.kuali.ole.sys.batch.BatchInputFileSetType#extractFileUserIdentifiers(org.kuali.rice.kim.api.identity.Person, java.util.List)
*/
public Set<String> extractFileUserIdentifiers(Person user, List<File> files) {
Set<String> extractedFileUserIdentifiers = new TreeSet<String>();
StringBuilder buf = new StringBuilder();
buf.append(FILE_NAME_PREFIX).append(FILE_NAME_PART_DELIMITER).append(user.getPrincipalName()).append(FILE_NAME_PART_DELIMITER);
String prefixString = buf.toString();
IOFileFilter prefixFilter = new PrefixFileFilter(prefixString);
IOFileFilter suffixFilter = new OrFileFilter(new SuffixFileFilter(EnterpriseFeederService.DATA_FILE_SUFFIX), new SuffixFileFilter(EnterpriseFeederService.RECON_FILE_SUFFIX));
IOFileFilter combinedFilter = new AndFileFilter(prefixFilter, suffixFilter);
for (File file : files) {
if (combinedFilter.accept(file)) {
String fileName = file.getName();
if (fileName.endsWith(EnterpriseFeederService.DATA_FILE_SUFFIX)) {
extractedFileUserIdentifiers.add(StringUtils.substringBetween(fileName, prefixString, EnterpriseFeederService.DATA_FILE_SUFFIX));
}
else if (fileName.endsWith(EnterpriseFeederService.RECON_FILE_SUFFIX)) {
extractedFileUserIdentifiers.add(StringUtils.substringBetween(fileName, prefixString, EnterpriseFeederService.RECON_FILE_SUFFIX));
}
else {
LOG.error("Unable to determine file user identifier for file name: " + fileName);
throw new RuntimeException("Unable to determine file user identifier for file name: " + fileName);
}
}
}
return extractedFileUserIdentifiers;
}
示例14: getReportsToAggregateIntoReport
import org.apache.commons.io.filefilter.PrefixFileFilter; //导入依赖的package包/类
protected List<File> getReportsToAggregateIntoReport(String documentNumber) {
File inputDirectory = new File(temporaryReportsDirectory);
if (!inputDirectory.exists() || !inputDirectory.isDirectory()) {
LOG.error(temporaryReportsDirectory + " does not exist or is not a directory.");
throw new RuntimeException("Unable to locate temporary reports directory");
}
String filePrefix = documentNumber + "_" + temporaryReportFilenameComponent;
FileFilter filter = FileFilterUtils.andFileFilter(
new PrefixFileFilter(filePrefix), new SuffixFileFilter(temporaryReportFilenameSuffix));
// FSKD-244, KFSMI-5424 sort with filename, just in case
List<File> fileList = Arrays.asList(inputDirectory.listFiles(filter));
Comparator fileNameComparator = new Comparator() {
public int compare(Object obj1, Object obj2) {
if (obj1 == null) {
return -1;
}
if (obj2 == null) {
return 1;
}
File file1 = (File) obj1;
File file2 = (File) obj2;
return ((Comparable) file1.getName()).compareTo(file2.getName());
}
};
Collections.sort(fileList, fileNameComparator);
return fileList ;
}
示例15: isTranscodingStepInstalled
import org.apache.commons.io.filefilter.PrefixFileFilter; //导入依赖的package包/类
private boolean isTranscodingStepInstalled(String step) {
if (StringUtils.isEmpty(step)) {
return true;
}
String executable = StringUtil.split(step)[0];
PrefixFileFilter filter = new PrefixFileFilter(executable);
String[] matches = transcodingService.getTranscodeDirectory().list(filter);
return matches != null && matches.length > 0;
}