本文整理汇总了Java中com.google.common.io.PatternFilenameFilter类的典型用法代码示例。如果您正苦于以下问题:Java PatternFilenameFilter类的具体用法?Java PatternFilenameFilter怎么用?Java PatternFilenameFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PatternFilenameFilter类属于com.google.common.io包,在下文中一共展示了PatternFilenameFilter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: copyIDEALicense
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
public static void copyIDEALicense(final String sandboxHome) {
File sandboxSystemPath = new File(sandboxHome, "system");
File systemPath = new File(PathManager.getSystemPath());
File[] runningIdeaLicenses = systemPath.listFiles(new PatternFilenameFilter("idea\\d+\\.key"));
if (runningIdeaLicenses != null) {
for (File license : runningIdeaLicenses) {
File devIdeaLicense = new File(sandboxSystemPath, license.getName());
if (!devIdeaLicense.exists()) {
try {
FileUtil.copy(license, devIdeaLicense);
}
catch (IOException e) {
LOG.error(e);
}
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:IdeaLicenseHelper.java
示例2: getExampleTurtleFileNames
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
/**
* Method to get file names from the util package
*
* @return File names as List<>
*/
public static List<String> getExampleTurtleFileNames () {
List<String> fileNames = new ArrayList();
URL fdpFileURL = ExampleTurtleFiles.class.getResource(
EXAMPLE_FDP_METADATA_FILE);
String sourceFileURI = fdpFileURL.getPath();
sourceFileURI = sourceFileURI.replace(EXAMPLE_FDP_METADATA_FILE, "");
// Matches only turtle files
Pattern pattern = Pattern.compile("^.*.ttl");
FilenameFilter filterByExtension = new PatternFilenameFilter(pattern);
File dir = new File(sourceFileURI);
File[] files = dir.listFiles(filterByExtension);
for (File file: files) {
fileNames.add(file.getName());
}
LOGGER.info("Turtle files in util packaage " + fileNames.toString());
return fileNames;
}
开发者ID:DTL-FAIRData,项目名称:ODEX-FAIRDataPoint,代码行数:24,代码来源:ExampleTurtleFiles.java
示例3: signalEnd
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
@Override
@Async
public void signalEnd(final List<RecorderInfo> recorders, final File workingDir) {
// let's merge the results
String fileName = recorders.get(0).getOutputFile().getName();
int i = 1;
File[] genDirs = workingDir.listFiles(new PatternFilenameFilter(".*gen-\\d+"));
for (File genDir : genDirs) {
File file = new File(genDir, fileName);
try {
Files.copy(file, new File(fileName + ".part" + i++));
} catch (IOException e) {
log.error("Could not copy '" + file.getName() + "' to '" + fileName + ".part" + i , e);
}
}
ResultFileMerger merger = new ResultFileMerger();
merger.merge(recorders, workingDir);
context.publishEvent(new ClusterMain.ExperimentEndedEvent(this));
}
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:25,代码来源:ExperimentEndHandler.java
示例4: runScriptsInDirectory
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
/**
* Run scripts in the directory if the file names match the pattern. This
* will try to run all scripts, even if some fail. Each script runs
* independently in its own environment.
*
* TODO: Add boolean recursive option
*
* @param map
* initial environment
* @param directoryName
* directory where scripts should be found
* @param pattern
* Only run scripts whose name match this file name pattern.
*/
public static void runScriptsInDirectory(Map<String, Object> map,
String directoryName, final String pattern) {
File dir = new File(directoryName);
ArrayList<String> fileNames = new ArrayList<String>();
FilenameFilter filter = pattern == null ? unravlScriptFile
: new PatternFilenameFilter(pattern);
if (dir.exists() && dir.isDirectory()) {
File files[] = dir.listFiles(filter);
for (File file : files) {
if (!file.isDirectory())
fileNames.add(file.getAbsolutePath());
}
int count = runScriptFiles(map,
fileNames.toArray(new String[fileNames.size()]));
System.out.println(String.format("Ran %s scripts in %s%s", count,
directoryName, pattern == null ? "" : " matching pattern "
+ pattern));
} else {
throw new AssertionError(String.format(
"Warning: directory %s does not exist.", dir));
}
}
开发者ID:sassoftware,项目名称:unravl,代码行数:37,代码来源:JUnitWrapper.java
示例5: tryScriptsInDirectory
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
public static void tryScriptsInDirectory(UnRAVLRuntime runtime,
Map<String, Object> env, String directoryName, String pattern) {
File dir = new File(directoryName);
ArrayList<String> fileNames = new ArrayList<String>();
FilenameFilter filter = pattern == null ? unravlScriptFile
: new PatternFilenameFilter(pattern);
if (dir.exists() && dir.isDirectory()) {
File files[] = dir.listFiles(filter);
for (File file : files) {
if (!file.isDirectory())
fileNames.add(file.getAbsolutePath());
}
int count = JUnitWrapper.tryScriptFiles(
runtime == null ? new UnRAVLRuntime(env) : runtime,
fileNames.toArray(new String[fileNames.size()]));
System.out.println(String.format("Tried %s scripts in %s%s", count,
directoryName, pattern == null ? "" : " matching pattern "
+ pattern));
} else {
throw new AssertionError(String.format(
"Warning: directory %s does not exist.", dir));
}
}
开发者ID:sassoftware,项目名称:unravl,代码行数:24,代码来源:JUnitWrapper.java
示例6: SeqVectorReader
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
public SeqVectorReader(String dirName, String filterPattern, boolean shuffle) throws IOException{
dir = new File(dirName);
listFiles = dir.listFiles(new PatternFilenameFilter(dir.getName() + filterPattern));
if (shuffle){
shuffle(listFiles);
System.out.println(Arrays.toString(listFiles));
}else {
//sort by blockid
}
if (listFiles == null || listFiles.length == 0){
throw new RuntimeException("blocks not found!");
}
msgpack = new MessagePack();
unpacker = msgpack.createUnpacker(new BufferedInputStream(new FileInputStream(listFiles[blockIt]),1024 * 1024 * 2));
stat = DataSetInfo.load(new File(dirName + "/" + dir.getName() + ".sta"));
vt = VectorType.valueOf(stat.getProperty("vectorType"));
}
开发者ID:lgnlgn,项目名称:feluca,代码行数:19,代码来源:SeqVectorReader.java
示例7: MultiVectorReader
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
public MultiVectorReader(String dirName, int... parts) throws IOException{
if (parts == null){ //all
File dir = new File(dirName);
File[] listFiles = dir.listFiles(new PatternFilenameFilter(dir.getName() + "\\.v\\.\\d+\\.dat"));
parts = new int[listFiles.length];
for(int i = 0 ; i < listFiles.length; i++){
String blockPart = listFiles[i].getName().split("\\.v\\.")[1];
int blockId = Integer.parseInt(blockPart.substring(0, blockPart.indexOf(".dat")));
parts[i] = blockId;
}
}else{
this.parts = parts;
}
readers = new ArrayList<SeqVectorReader>(parts.length);
currentVectors = new ArrayList<Vector>(parts.length);
for(int i = 0 ; i < parts.length; i++){
readers.add(new SeqVectorReader(dirName, "\\.v\\." + parts[i] +"\\.dat"));
}
vt = readers.get(0).getVectorType();
dir = readers.get(0).getDataDir();
}
开发者ID:lgnlgn,项目名称:feluca,代码行数:23,代码来源:MultiVectorReader.java
示例8: list
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Iterable<StorageMetadata> list() {
final Set<StorageMetadata> metadatas = Sets.newHashSet();
final File[] files = baseStorageDir().listFiles(new PatternFilenameFilter(".*\\.unc"));
if (files != null) {
for (final File file : files) {
final StorageMetadata sm = new StorageMetadata();
sm.setCreationTimestamp(new Date(file.lastModified()));
sm.setHandle(handleFromFile(file));
sm.setUncompressedSize(file.length());
metadatas.add(sm);
}
}
return metadatas;
}
开发者ID:NCIP,项目名称:caarray,代码行数:19,代码来源:FilesystemDataStorage.java
示例9: getPlayer
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
private String getPlayer(String check)
{
synchronized (players)
{
if (players.isEmpty())
{
File worldFolder = ess.getServer().getWorlds().get(0).getWorldFolder();
File playersFolder = new File(worldFolder, "players");
for (String filename : playersFolder.list(new PatternFilenameFilter(".+\\.dat")))
{
String name = filename.substring(0, filename.length() - 4).toLowerCase(Locale.ENGLISH);
String sanitizedName = Util.sanitizeFileName(name);
String mapName = players.get(sanitizedName);
if (mapName != null && !mapName.equals(name))
{
players.put(sanitizedName, BROKENNAME);
}
else
{
players.put(sanitizedName, name);
}
}
}
}
return players.get(check);
}
开发者ID:Curtis3321,项目名称:Essentials,代码行数:27,代码来源:UpdateUserFiles.java
示例10: LoadRunner
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
/**
* @param client recommender to load
* @param dataDirectory a directory containing data files from which user and item IDs should be read
* @param steps number of load steps to run
*/
public LoadRunner(MyrrixRecommender client, File dataDirectory, int steps) throws IOException {
Preconditions.checkNotNull(client);
Preconditions.checkNotNull(dataDirectory);
Preconditions.checkArgument(steps > 0);
log.info("Reading IDs...");
FastIDSet userIDsSet = new FastIDSet();
FastIDSet itemIDsSet = new FastIDSet();
Splitter comma = Splitter.on(',');
for (File f : dataDirectory.listFiles(new PatternFilenameFilter(".+\\.csv(\\.(zip|gz))?"))) {
for (CharSequence line : new FileLineIterable(f)) {
Iterator<String> it = comma.split(line).iterator();
userIDsSet.add(Long.parseLong(it.next()));
itemIDsSet.add(Long.parseLong(it.next()));
}
}
this.client = client;
this.uniqueUserIDs = userIDsSet.toArray();
this.uniqueItemIDs = itemIDsSet.toArray();
this.steps = steps;
}
开发者ID:myrrix,项目名称:myrrix-recommender,代码行数:28,代码来源:LoadRunner.java
示例11: generateClasspath
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
/** Generates classpath string using paths of all plugins available and the Bukkit JAR */
private String generateClasspath()
{
File pluginDir = new File("plugins/").getAbsoluteFile();
File[] plugins = pluginDir.listFiles( new PatternFilenameFilter(".+\\.jar") );
String classpath = BUKKIT_JAR;
for (File plugin : plugins)
classpath += ";" + plugin.getAbsolutePath();
return classpath;
}
开发者ID:Gamealition,项目名称:SoftPlugin,代码行数:13,代码来源:Compiler.java
示例12: afterPropertiesSet
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws IOException {
File[] jsonfiles = defDir.listFiles(new PatternFilenameFilter(".*\\.json$"));
configure(jsonfiles, jsonObjectMapper);
File[] yamlfiles = defDir.listFiles(new PatternFilenameFilter(".*\\.yaml$"));
configure(yamlfiles, yamlObjectMapper);
}
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:8,代码来源:StubConfigLoader.java
示例13: doPartition
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
void doPartition(VectorReader reader, int shards, String suffix) throws IOException{
assert (isPowerOfTwo(shards) == true);
File[] dats = reader.getDataDir().listFiles(new PatternFilenameFilter(".*\\.v\\.\\d+\\.dat"));
for(File dat : dats){
System.out.print(dat.getName() + ";");
dat.delete();
}
String dataName = reader.getDataDir().getName();
HashPartitioner partitioner = new HashPartitioner(shards);
String blockPathTemplate = reader.getDataDir().getAbsolutePath() + "/" + dataName + ".v.%d.dat" + suffix;
ArrayList<Packer> packers = new ArrayList<Packer>(shards);
MessagePack messagePack = new MessagePack();
for(int i = 0 ; i < shards;i++){ //output
packers.add(messagePack.createPacker(
new BufferedOutputStream(new FileOutputStream(String.format(blockPathTemplate, i)), 1024 * 1024 * 2)));
}
int count = 0;
for(Vector v = reader.getNextVector(); v!= null; v = reader.getNextVector()){
List<Vector> divided = v.divideByFeature(partitioner);
for(int i = 0 ; i < divided.size(); i++){
packers.get(i).write(true);
divided.get(i).pack(packers.get(i));
}
count ++;
if (count % 2000 == 0){
for(int i = 0 ; i < packers.size(); i++){
packers.get(i).flush();
}
System.out.print("*");
}
}
for(int i = 0 ; i < packers.size(); i++){
packers.get(i).write(false).close();
}
}
开发者ID:lgnlgn,项目名称:feluca,代码行数:38,代码来源:VectorPartitioner.java
示例14: getAvailableSettingsFiles
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
/**
* @return the availableSettingsFiles
*/
public Set<String> getAvailableSettingsFiles() {
if (availableSettingsFiles == null) {
String[] list = settingsDir.list(new PatternFilenameFilter(".*\\.xml"));
if (list == null) {
availableSettingsFiles = newTreeSet();
} else {
availableSettingsFiles = newTreeSet(asList(list));
}
}
return ImmutableSet.copyOf(availableSettingsFiles);
}
开发者ID:mgm-tp,项目名称:perfload-loadprofiles,代码行数:15,代码来源:ConfigController.java
示例15: deleteOldExtractors
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
private void deleteOldExtractors(File dir, String classSuffix) {
File[] files = dir.listFiles(new PatternFilenameFilter(".*" + classSuffix + ".java"));
if (files != null)
for (File e : files)
e.delete();
dir.mkdirs();
}
开发者ID:pescuma,项目名称:buildhealth,代码行数:8,代码来源:WarningsExtractorGenerator.java
示例16: loadReport
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
/**
* Custom separate dload report component, so it can be called elsewhere, or overwritten by child Providers. Checks
* the "report" to ensure it is a directory then looks for reportconf.yaml or reportconf.json inside the file. If it
* exists loads it.
* @param result The collection of reports to load the contents into.
* @param report The directory that contains the report files.
* @param reportId The report id
* @throws IOException
*/
protected void loadReport(ReportsConfig result, File report, String reportId) throws IOException {
if (report.isDirectory())
{
FilenameFilter configYamlFilter = new PatternFilenameFilter("^reportconf.(yaml|json)$");
File[] selectYaml = report.listFiles(configYamlFilter);
if (selectYaml != null && selectYaml.length == 1)
{
File selectedYaml = selectYaml[0];
loadReport(result, FileUtils.openInputStream(selectedYaml), reportId);
}
}
}
开发者ID:base2Services,项目名称:kagura,代码行数:22,代码来源:FileReportsProvider.java
示例17: getStructureFile
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
private File getStructureFile(File dirWithDb) throws InvalidFileException {
//Look for the STR file
File[] dbfiles = dirWithDb.listFiles(new PatternFilenameFilter(Pattern.compile(".*\\.STR")));
if (dbfiles == null || dbfiles.length != 1) {
throw new InvalidFileException("I expected one .STR file in the zip");
}
return dbfiles[0];
}
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:9,代码来源:DataPerfectLoader.java
示例18: readAndCopyDataFiles
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
private static Multimap<Long,RecommendedItem> readAndCopyDataFiles(File dataDir, File tempDir) throws IOException {
Multimap<Long,RecommendedItem> data = ArrayListMultimap.create();
for (File dataFile : dataDir.listFiles(new PatternFilenameFilter(".+\\.csv(\\.(zip|gz))?"))) {
log.info("Reading {}", dataFile);
int count = 0;
for (CharSequence line : new FileLineIterable(dataFile)) {
Iterator<String> parts = COMMA_TAB_SPLIT.split(line).iterator();
long userID = Long.parseLong(parts.next());
long itemID = Long.parseLong(parts.next());
if (parts.hasNext()) {
String token = parts.next().trim();
if (!token.isEmpty()) {
data.put(userID, new GenericRecommendedItem(itemID, LangUtils.parseFloat(token)));
}
// Ignore remove lines
} else {
data.put(userID, new GenericRecommendedItem(itemID, 1.0f));
}
if (++count % 1000000 == 0) {
log.info("Finished {} lines", count);
}
}
Files.copy(dataFile, new File(tempDir, dataFile.getName()));
}
return data;
}
开发者ID:myrrix,项目名称:myrrix-recommender,代码行数:28,代码来源:ReconstructionEvaluator.java
示例19: ChromeWebDriverFactory
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
public ChromeWebDriverFactory() {
super( //
BrowserType.CHROME, //
(targetDirectory) -> {
final String extension = getExecutableExtension(true);
final Pattern executablePattern =
Pattern.compile("chromedriver-(?<version>.*)" + extension);
final File[] files =
targetDirectory.listFiles(new PatternFilenameFilter(executablePattern));
if (files == null || files.length != 1) {
return Optional.empty();
}
final File executable = files[0];
final Matcher executableMatcher = executablePattern.matcher(executable.getName());
if (!executableMatcher.find()) {
throw new IllegalStateException(
String.format("Unable to determine version of executable %s", executable));
}
final String version = executableMatcher.group("version");
return Optional
.of(new DownloadWebDriverExecutable.WebDriverExecutable(executable, version));
}, //
() -> getString(LATEST_RELEASE_URL), //
(version, targetDirectory) -> {
final String system;
if (SystemUtils.IS_OS_WINDOWS) {
system = "win32";
} else if (SystemUtils.IS_OS_MAC) {
system = "mac64";
} else if (SystemUtils.IS_OS_LINUX) {
final StringBuilder linuxBuilder = new StringBuilder("linux");
// TODO this property does not reflect the OS architecture, it is the VM`s "bitness"
if (SystemUtils.OS_ARCH.contains("64")) {
linuxBuilder.append("64");
} else {
linuxBuilder.append("32");
}
system = linuxBuilder.toString();
} else {
throw new UnsupportedOperationException(
String.format("Unsupported operation system: %s %s", SystemUtils.OS_NAME,
SystemUtils.OS_VERSION));
}
LOGGER.debug("System '{}' detected.", system);
final String downloadUrl =
DOWNLOAD_URL + String.format("/%s/chromedriver_%s.zip", version, system);
LOGGER.debug("Download chromedriver from {}", downloadUrl);
downloadZipAndExtract(downloadUrl, targetDirectory);
final File chromeDriverFile = new File(targetDirectory,
String.format("chromedriver%s", getExecutableExtension(false)));
final File chromeDriverFileWithVersion = new File(targetDirectory,
String.format("chromedriver-%s%s", version, getExecutableExtension(false)));
if (!chromeDriverFile.renameTo(chromeDriverFileWithVersion)) {
throw new RuntimeException();
}
if (!chromeDriverFileWithVersion.setExecutable(true, false)) {
throw new RuntimeException();
}
return new DownloadWebDriverExecutable.WebDriverExecutable(chromeDriverFileWithVersion,
version);
}, //
ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY //
);
}
开发者ID:klaushauschild1984,项目名称:selenium-toys,代码行数:65,代码来源:ChromeWebDriverFactory.java
示例20: downloadUpdate
import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
public Observable<Status> downloadUpdate(final String uri) {
return Observable.unsafeCreate(subscriber -> {
try {
File directory = new File(context.getCacheDir(), "updates");
if (!directory.exists() && !directory.mkdirs()) {
Crashlytics.log("Could not create apk directory: " + directory);
}
// clear all previous files
File[] files = directory.listFiles(new PatternFilenameFilter("bs-update.*apk"));
for (File file : files) {
if (!file.delete()) {Crashlytics.log("Could not delete file: " + file);
}
}
// and download the new file.
File tempFile = File.createTempFile(
"bs-update", ".apk",
directory);
try (OutputStream output = new FileOutputStream(tempFile)) {
Request request = new Request.Builder().url(uri).build();
Call call = okHttpClient.newCall(request);
subscriber.add(Subscriptions.create(() -> call.cancel()));
Response response = call.execute();
Interval interval = new Interval(250);
try (CountingInputStream input = new CountingInputStream(response.body().byteStream())) {
int count;
byte[] buffer = new byte[1024 * 32];
while ((count = ByteStreams.read(input, buffer, 0, buffer.length)) > 0) {
output.write(buffer, 0, count);
if (interval.check()) {
float progress = input.getCount() / (float) response.body().contentLength();
subscriber.onNext(new Status(progress, null));
}
}
}
}
subscriber.onNext(new Status(1, tempFile));
subscriber.onCompleted();
} catch (Throwable error) {
subscriber.onError(error);
}
});
}
开发者ID:M4lik,项目名称:burning-series,代码行数:51,代码来源:DownloadService.java
注:本文中的com.google.common.io.PatternFilenameFilter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论