本文整理匯總了Java中org.apache.commons.io.IOCase類的典型用法代碼示例。如果您正苦於以下問題:Java IOCase類的具體用法?Java IOCase怎麽用?Java IOCase使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IOCase類屬於org.apache.commons.io包,在下文中一共展示了IOCase類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getResourcesWithExtension
import org.apache.commons.io.IOCase; //導入依賴的package包/類
public ArrayList<String> getResourcesWithExtension(String ext, String containerName) {
ArrayList<String> ret = new ArrayList<String>();
if (containerName != null) {
String[] names = StringUtils.split(containerName, "/");
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = wsRoot.findMember(new Path("/" + names[0]));
IPath loc = resource.getLocation();
File prjLoc = new File(loc.toString());
Collection<File> res = FileUtils.listFiles(prjLoc, FileFilterUtils.suffixFileFilter(ext, IOCase.INSENSITIVE), TrueFileFilter.INSTANCE);
for (File file : res)
ret.add(file.getAbsolutePath());
}
return ret;
}
示例2: FileAlterationObserver
import org.apache.commons.io.IOCase; //導入依賴的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;
}
}
示例3: getModels
import org.apache.commons.io.IOCase; //導入依賴的package包/類
/**
* Gets the models.
*
* @return the models
*/
public static String[] getModels() {
File dir = new File(Config.getConfiguration().getString(MODELPATH));
LOG.info("Loading Models from... " + dir.getAbsolutePath());
List<String> models = new ArrayList<>();
String[] modelNames = getModelNames();
List<String> wildCardPath = Arrays.stream(modelNames).map(model -> {
return "en-ner-" + model + "*.bin";
}).collect(Collectors.toList());
FileFilter fileFilter = new WildcardFileFilter(wildCardPath,
IOCase.INSENSITIVE);
List<String> filePath = Arrays.asList(dir.listFiles(fileFilter))
.stream().map(file -> file.getAbsolutePath())
.collect(Collectors.toList());
return filePath.toArray(new String[filePath.size()]);
}
示例4: FileAlterationObserver
import org.apache.commons.io.IOCase; //導入依賴的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;
}
}
示例5: forFile
import org.apache.commons.io.IOCase; //導入依賴的package包/類
/** The extension for the given file. */
public static Optional<FileExt> forFile(String path) {
int n = path.length();
int dot = path.lastIndexOf('.');
if (dot < 0 || dot + 1 == n) { return Optional.absent(); }
for (int i = dot + 1; i < n; ++i) {
char ch = path.charAt(i);
if (ch == '/' || ch == '\\') {
return Optional.absent();
}
}
String ext = path.substring(dot + 1);
if (IOCase.SYSTEM.isCaseSensitive()) {
// TODO: This may not do the right thing on Mac.
// TODO: Should this be done in valueOf?
ext = ext.toLowerCase(Locale.ENGLISH); // No locale-specific folding
}
return Optional.of(valueOf(ext));
}
示例6: findFilesToAnalyze
import org.apache.commons.io.IOCase; //導入依賴的package包/類
public static List<String> findFilesToAnalyze(String dirPath) {
IOFileFilter gitFilter = FileFilterUtils.notFileFilter(
FileFilterUtils.nameFileFilter(".git")
);
File dir = new File(dirPath);
String[] phpExt = new String[] {"php"};
IOFileFilter phpFilter = new SuffixFileFilter(phpExt, IOCase.INSENSITIVE);
List<File> files = (List<File>) FileUtils.listFiles(dir, phpFilter, gitFilter);
List<String> results = new ArrayList<String>();
for (File f : files) {
try {
results.add(f.getCanonicalPath());
} catch (IOException e) {
e.printStackTrace();
}
}
return results;
}
示例7: equals
import org.apache.commons.io.IOCase; //導入依賴的package包/類
/**
* Checks whether two filenames are equal, optionally normalizing and providing
* control over the case-sensitivity.
*
* @param filename1 the first filename to query, may be null
* @param filename2 the second filename to query, may be null
* @param normalized whether to normalize the filenames
* @param caseSensitivity what case sensitivity rule to use, null means case-sensitive
* @return true if the filenames are equal, null equals null
* @since 1.3
*/
public static boolean equals(
String filename1, String filename2,
boolean normalized, IOCase caseSensitivity) {
if (filename1 == null || filename2 == null) {
return filename1 == null && filename2 == null;
}
if (normalized) {
filename1 = normalize(filename1);
filename2 = normalize(filename2);
if (filename1 == null || filename2 == null) {
throw new NullPointerException(
"Error normalizing one or both of the file names");
}
}
if (caseSensitivity == null) {
caseSensitivity = IOCase.SENSITIVE;
}
return caseSensitivity.checkEquals(filename1, filename2);
}
示例8: FileAlterationObserver
import org.apache.commons.io.IOCase; //導入依賴的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;
}
}
示例9: PathAlterationObserver
import org.apache.commons.io.IOCase; //導入依賴的package包/類
/**
* The comparison between path is always case-sensitive in this general file system context.
*/
public PathAlterationObserver(final FileStatusEntry rootEntry, final PathFilter pathFilter)
throws IOException {
if (rootEntry == null) {
throw new IllegalArgumentException("Root entry is missing");
}
if (rootEntry.getPath() == null) {
throw new IllegalArgumentException("Root directory is missing");
}
this.rootEntry = rootEntry;
this.pathFilter = pathFilter;
this.fs = rootEntry.getPath().getFileSystem(new Configuration());
// By default, the comparsion is case sensitive.
this.comparator = new Comparator<Path>() {
@Override
public int compare(Path o1, Path o2) {
return IOCase.SENSITIVE.checkCompareTo(o1.toUri().toString(), o2.toUri().toString());
}
};
}
示例10: VFSManager
import org.apache.commons.io.IOCase; //導入依賴的package包/類
public VFSManager(File systemDir, File userDir) {
super(systemDir, userDir, new SuffixFileFilter(".xml", IOCase.INSENSITIVE));
Comparator<File> nameComparator = new Comparator<File>() {
@Override
public int compare(File f1, File f2) {
// we want vfs.xml to loaded first, always.
if (f1.getName().equals("x-vfs.xml"))
return Integer.MIN_VALUE;
if (f2.getName().equals("x-vfs.xml"))
return Integer.MAX_VALUE;
return f1.getName().compareToIgnoreCase(f2.getName());
}
};
getSystemFiles().setNameComparator(nameComparator);
}
示例11: buildTrainingDataFromCorpus
import org.apache.commons.io.IOCase; //導入依賴的package包/類
public static void buildTrainingDataFromCorpus(String dataSetName,
File corpusRoot, FVGenerator fvGenerator, File dest)
throws IOException {
Collection<File> children = FileUtils.listFiles(corpusRoot,
new RegexFileFilter(".+\\.txt", IOCase.INSENSITIVE), DirectoryFileFilter.INSTANCE);
ArffSaver saver = new ArffSaver();
saver.setFile(dest);
saver.setRetrieval(Saver.INCREMENTAL);
boolean first = true;
for (File textFile : children) {
Instances dataSet = buildTrainingDataFromFile(dataSetName, textFile, fvGenerator);
if (first) {
saver.setStructure(dataSet);
first = false;
}
for (int i = 0; i < dataSet.numInstances(); ++i) {
saver.writeIncremental(dataSet.instance(i));
}
}
saver.getWriter().flush();
}
示例12: RegexFileFilter
import org.apache.commons.io.IOCase; //導入依賴的package包/類
/**
* Construct a new regular expression filter with the specified flags case sensitivity.
*
* @param pattern regular string expression to match
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the pattern is null
*/
public RegexFileFilter(String pattern, IOCase caseSensitivity) {
if (pattern == null) {
throw new IllegalArgumentException("Pattern is missing");
}
int flags = 0;
if (caseSensitivity != null && !caseSensitivity.isCaseSensitive()) {
flags = Pattern.CASE_INSENSITIVE;
}
this.pattern = Pattern.compile(pattern, flags);
}
示例13: NameFileFilter
import org.apache.commons.io.IOCase; //導入依賴的package包/類
/**
* Construct a new name file filter specifying case-sensitivity.
*
* @param name the name to allow, must not be null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the name is null
*/
public NameFileFilter(String name, IOCase caseSensitivity) {
if (name == null) {
throw new IllegalArgumentException("The wildcard must not be null");
}
this.names = new String[] {name};
this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity);
}
示例14: WildcardFileFilter
import org.apache.commons.io.IOCase; //導入依賴的package包/類
/**
* Construct a new wildcard filter for a single wildcard specifying case-sensitivity.
*
* @param wildcard the wildcard to match, not null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the pattern is null
*/
public WildcardFileFilter(String wildcard, IOCase caseSensitivity) {
if (wildcard == null) {
throw new IllegalArgumentException("The wildcard must not be null");
}
this.wildcards = new String[] { wildcard };
this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity);
}
示例15: NameFileFilter
import org.apache.commons.io.IOCase; //導入依賴的package包/類
/**
* Construct a new name file filter specifying case-sensitivity.
*
* @param name the name to allow, must not be null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the name is null
*/
public NameFileFilter(String name, IOCase caseSensitivity) {
if (name == null) {
throw new IllegalArgumentException("The wildcard must not be null");
}
this.names = new String[] {name};
this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
}