Java 类org.apache.commons.io.filefilter.WildcardFileFilter 实例源码

项目:second-hand-log    文件:FsmIT.java   
/**
 * Check if FSM is valid.
 *
 * @throws Exception the exception
 */
@Test
public void testisFSMValid() throws Exception {
  final File directory = new File("target");
  final Collection<File> files = FileUtils.listFiles(directory, new WildcardFileFilter("*.fsm"),
      null);
  final Iterator<File> iterator = files.iterator();
  assertTrue("FSM doesn't contain any files", iterator.hasNext());
  if (iterator.hasNext()) {
    try (final ZipFile _fsmZip = new ZipFile(iterator.next())) {
      final ZipEntry license = _fsmZip.getEntry("LICENSE");
      errors.checkThat("Couldn't find module descriptor (module.xml) in fsm file", license,
          is(notNullValue()));
      final ZipEntry moduleXML = _fsmZip.getEntry(MODULE_DESCRIPTOR);
      errors.checkThat("Couldn't find module descriptor (module.xml) in fsm file", moduleXML,
          is(notNullValue()));
      final ZipEntry consoleLib = _fsmZip.getEntry("lib/console-"
          + pomProperties.getProperty("version") + ".jar");
      errors.checkThat("Couldn't find lib in fsm file", consoleLib, is(notNullValue()));
      final ZipEntry toolbarLib = _fsmZip.getEntry("lib/toolbar-"
          + pomProperties.getProperty("version") + ".jar");
      errors.checkThat("Couldn't find lib in fsm file", toolbarLib, is(notNullValue()));
    }
  }

}
项目:mtgo-best-bot    文件:ProcessManager.java   
private String getExecutable() {
    File supposedExecutable = new File(executableDir + executableName);

    if(supposedExecutable.exists()) {
        return supposedExecutable.getAbsolutePath();
    } else {
        Collection<File> theExecutable = FileUtils.listFiles(new File(executableDir), new WildcardFileFilter(executableName), TrueFileFilter.INSTANCE);

        if(theExecutable != null || theExecutable.size() > 1 || theExecutable.isEmpty()) {
            File newestExecutable = theExecutable.stream().reduce(new File(""),
                    (aFile, newestFile) -> {
                        if(aFile.lastModified() > newestFile.lastModified()) {
                            return aFile;
                        }

                        return newestFile;
                    });

            return newestExecutable.getAbsolutePath();
        } else if(theExecutable.size() == 1) {
            return ((File)CollectionUtils.get(theExecutable, 0)).getAbsolutePath();
        } else {
            throw new RuntimeException("Could not determine executable path");
        }
    }
}
项目:verify-hub    文件:FileBackedConfigDataSource.java   
@Override
public Collection<T> loadConfig() {
    Collection<T> configData = new ArrayList<>();
    final File configDirectory = new File(configuration.getDataDirectory(), dataDirectory);
    final File[] dataFiles = configDirectory.listFiles((FilenameFilter) new WildcardFileFilter("*.yml"));
    if (dataFiles == null) {
        throw ConfigValidationException.createFileReadError(configDirectory.getAbsolutePath());
    }

    for (File dataFile : dataFiles) {
        T data;
        try {
            data = configurationFactory.build(dataFile);
        } catch (IOException | ConfigurationException e) {
            throw Throwables.propagate(e);
        }
        configData.add(data);

    }
    return configData;
}
项目:endpoint-health    文件:EndPointHealthServiceImpl.java   
private void cleanDatabaseFiles() {
    final File databaseFile = endPointHealthConfiguration.databaseFile();
    final File parentFile = databaseFile.getParentFile();

    if (parentFile == null || !parentFile.exists()) {
        return;
    }

    FileUtils.listFiles(parentFile,
        new WildcardFileFilter(databaseFile.getName() + "*"), null).forEach(file -> {
            try {
                FileUtils.forceDelete(file);
                LOGGER.info(file + " deleted");
            } catch (final Exception e) {
                throw new EndPointHealthException(e);
            }
        });
}
项目:obevo    文件:DirectoryAssert.java   
/**
 * Primitive DB comparison method
 * We just compare file names, not the subdirecory structure also
 * (so this would fail if multiple subdirectories had the same file name)
 */
public static void assertDirectoriesEqual(File expected, File actual) {
    MutableList<File> expectedFiles = FastList.newList(FileUtils.listFiles(expected, new WildcardFileFilter("*"),
            DIR_FILE_FILTER));
    expectedFiles = expectedFiles.sortThisBy(toRelativePath(expected));
    MutableList<File> actualFiles = FastList.newList(FileUtils.listFiles(actual, new WildcardFileFilter("*"),
            DIR_FILE_FILTER));
    actualFiles = actualFiles.sortThisBy(toRelativePath(actual));

    assertEquals(
            String.format("Directories did not have same # of files:\nExpected: %1$s\nbut was: %2$s",
                    expectedFiles.makeString("\n"), actualFiles.makeString("\n")),
            expectedFiles.size(), actualFiles.size());
    for (int i = 0; i < expectedFiles.size(); i++) {
        File expectedFile = expectedFiles.get(i);
        File actualFile = actualFiles.get(i);

        String expectedFilePath = getRelativePath(expectedFile, expected);
        String actualFilePath = getRelativePath(actualFile, actual);
        System.out.println("Comparing" + expectedFilePath + " vs " + actualFilePath);

        assertEquals("File " + i + " [" + expectedFile + " vs " + actualFile
                + " does not match paths relative from their roots", expectedFilePath, actualFilePath);
        FileAssert.assertEquals("Mismatch on file " + expectedFile.getAbsolutePath(), expectedFile, actualFile);
    }
}
项目:opennlp-enhancer    文件:ModelLoaderConfig.java   
/**
 * 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()]);
}
项目:opennlp-enhancer    文件:ModelLoaderConfig.java   
/**
 * Gets the models. This method is used if ModelPath is passed as parameter.
 * 
 *
 * @return the models
 */
public static String[] getModels(String modelDirectory) {
    File dir = new File(modelDirectory);

    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()]);
}
项目:bigstreams    文件:TestDirectoryPollingThread.java   
@Test
public void testSeeNewFiles() {

    MapTrackerMemory memory = new MapTrackerMemory();

    DirectoryPollingThread dpth = new DirectoryPollingThread("test",
            new SimpleFileDateExtractor(), memory);
    dpth.setDirectory(createFilesDir.getAbsolutePath());
    dpth.setFileFilter(new WildcardFileFilter("*.log"));

    dpth.run();

    assertEquals(newFilesArr.length, memory.getFileCount());

    // check that the memory contains all files in the newFilesArr
    for (File file : newFilesArr) {

        FileTrackingStatus status = memory.getFileStatus(file);
        assertNotNull(status);
        assertEquals("test", status.getLogType());
        assertEquals(file.lastModified(), status.getLastModificationTime());
        assertEquals(file.length(), status.getFileSize());

    }

}
项目:neural-style-gui    文件:FileUtils.java   
public static File[] getTempOutputStyles() {
    if (tempDir == null || !tempDir.isDirectory())
        return null;

    // Unix-like searching for styles
    FileFilter styleFileFilter = new WildcardFileFilter("*.json");
    File[] files = tempDir.listFiles(styleFileFilter);

    if (files != null && files.length > 1) {
        long[] fileIters = new long[files.length];
        for (int i = 0; i < files.length; i++) {
            try {
                fileIters[i] = Long.valueOf(FileUtils.getFileName(files[i]).replace("_", ""));
            } catch (Exception e) {
                fileIters[i] = 0;
            }
        }
        FileUtils.quickSort(fileIters, files, 0, files.length - 1);
    }

    return files;
}
项目:neural-style-gui    文件:FileUtils.java   
public static File[] getTempOutputImageIterations(File outputImage) {
    if (tempDir == null || !tempDir.isDirectory() || outputImage == null)
        return null;

    // Unix-like searching for image iterations
    String outputImageBase = getFileName(outputImage);
    FileFilter fileFilter = new WildcardFileFilter(String.format("%s_*.png", outputImageBase));
    File[] files = tempDir.listFiles(fileFilter);

    // sort the files by the iteration progress
    if (files != null && files.length > 1) {
        int[] fileIters = new int[files.length];
        for (int i = 0; i < files.length; i++)
            fileIters[i] = FileUtils.parseImageIteration(files[i]);
        FileUtils.quickSort(fileIters, files, 0, files.length - 1);

        // if the latest file was still being written to during the check
        // then replace it with the previous file (set will remove it)
        if (isFileBeingWritten(files[files.length - 1]))
            files[files.length - 1] = files[files.length - 2];
    }

    return files;
}
项目:checksumDatabase    文件:ChecksumManager.java   
/**
 * Creates an entry for each file and calculate a md5 checksum for the file.
 * 
 * @param dir
 * @throws NoSuchAlgorithmException
 * @throws ExecutionException
 * @throws InterruptedException
 * @throws IOException
 */
public void addEntriesFromDirectory(String contractAddress,String dir)
        throws IOException, InterruptedException, ExecutionException, NoSuchAlgorithmException {
    setManager(contractAddress);
    MessageDigest md = MessageDigest.getInstance(algorithm);

    File directory = new File(dir);
    FilenameFilter filter = new WildcardFileFilter(fileFilter);

    String[] list = directory.list(filter);
    for (String filename : list) {
        String completetFilename = dir+"/"+filename;
        addSingleFile(md, completetFilename);
    }
    listChecksumData(manager.contractAddress.withLeading0x());
}
项目:github-version-statistics    文件:JSONWriter.java   
/**
 * Returns all repositories found until now with the highest version that we
 * found for them.
 *
 * @return repo as key, highest seen version as value
 * @throws IOException If a file cannot be read
 */
public static Map<String, String> getHighestVersions() throws IOException {
    // read stats
    File[] files = STATS_DIR.listFiles((FilenameFilter)new WildcardFileFilter("stats*.json"));
    Preconditions.checkNotNull(files);

    Arrays.sort(files);

    Map<String, String> seenRepositoryVersions = new HashMap<>();
    for(File file : files) {
        List<String> lines = FileUtils.readLines(file, "UTF-8");
        for (String line : lines) {
            Holder holder = mapper.readValue(line, Holder.class);
            // now update the map of highest version per Repository for the next date
            addHigherVersions(seenRepositoryVersions, holder.getRepositoryVersions());
        }
    }

    return seenRepositoryVersions;
}
项目:pipegen    文件:PathUtilities.java   
public static Stream<Path> getFileOrFiles(Path fileOrDirectory, String filterExpression) {
    File[] files;
    PathMatcher matcher = FileSystems.getDefault().getPathMatcher(filterExpression);

    if(fileOrDirectory.getFileName().toString().contains("*"))
        return Lists.newArrayList(fileOrDirectory.toFile()
                .getParentFile()
                .listFiles((FileFilter)new WildcardFileFilter(
                        fileOrDirectory.getFileName().toString())))
                .stream()
                .map(File::toPath)
                .filter(p -> matcher.matches(p.getFileName()));
    else if(fileOrDirectory.toFile().isDirectory() && (files = fileOrDirectory.toFile().listFiles()) != null)
        return Lists.newArrayList(files)
                    .stream()
                    .map(File::toPath)
                    .filter(p -> p.toFile().isDirectory() || matcher.matches(p.getFileName()));
    else
        return Lists.newArrayList(new Path[] {fileOrDirectory}).stream();
}
项目:tibco-fcunit    文件:MenuPage.java   
public File getTheNewestFile(File directory, String extension) {
    File newestFile = null;
    if (directory == null || !directory.exists() || !directory.isDirectory()) {
        return newestFile;
    }

    FileFilter fileFilter = new WildcardFileFilter("*." + extension);
    File[] files = directory.listFiles(fileFilter);

    if (files.length > 0) {
        Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
        newestFile = files[0];
    }

    return newestFile;
}
项目:openreports    文件:ReportProviderImpl.java   
public ReportTemplate getReportTemplate(String templateName) throws ProviderException
{       
    File reportDirectory = new File(directoryProvider.getReportDirectory());        
    FileFilter templateFilter = new WildcardFileFilter(templateName + "*");
    File[] templateFiles = reportDirectory.listFiles(templateFilter);

    String[] revisions = new String[templateFiles.length];
    for (int i=0; i <  templateFiles.length; i++)
    {
        revisions[i] = templateFiles[i].getName();
    }

    Arrays.sort(revisions);

    ReportTemplate template = new ReportTemplate(templateName);
    template.setRevisions(revisions);        

    return template;
}
项目:tibco-codereview    文件:MenuPage.java   
public File getTheNewestFile(File directory, String extension) {
    File newestFile = null;
    if (directory == null || !directory.exists() || !directory.isDirectory()) {
        return newestFile;
    }

    FileFilter fileFilter = new WildcardFileFilter("*." + extension);
    File[] files = directory.listFiles(fileFilter);

    if (files.length > 0) {
        Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
        newestFile = files[0];
    }

    return newestFile;
}
项目:tibco-codereview    文件:CodeReviewInitialize.java   
public File getTheNewestFile(File directory, String extension) {
    File newestFile = null;
    if (directory == null || !directory.exists() || !directory.isDirectory()) {
        return newestFile;
    }

    FileFilter fileFilter = new WildcardFileFilter("*." + extension);
    File[] files = directory.listFiles(fileFilter);

    if (files.length > 0) {
        Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
        newestFile = files[0];
    }

    return newestFile;
}
项目:whatswrong    文件:BioNLP2009SharedTaskFormat.java   
/**
 * Loads files from the given directory with the extensions specified by the text fields of the accessory.
 *
 * @param file the directory load the corpus from.
 * @param from the starting instance index.
 * @param to   the end instance index.
 * @return a list of NLP instances loaded from the given file in the given interval.
 * @throws java.io.IOException if I/O goes wrong.
 */
public List<NLPInstance> load(final File file,
                              final int from,
                              final int to) throws IOException {
    ArrayList<NLPInstance> result = new ArrayList<NLPInstance>();
    int index = 0;
    for (final File txtFile : file.listFiles((FileFilter)
        new WildcardFileFilter("*." + txtExtensionField.getText().trim()))) {
        String filename = txtFile.getAbsolutePath();
        String prefix = filename.substring(0, filename.lastIndexOf("."));
        File proteinFile = new File(prefix + "." +
            proteinExtensionField.getText().trim());
        File eventFile = new File(prefix + "." +
            eventExtensionField.getText().trim());
        if (proteinFile.exists() && eventFile.exists()) {
            result.add(load(txtFile, proteinFile, eventFile));
            monitor.progressed(index++);
        }
    }
    return result;
}
项目:sakai    文件:SiteAction.java   
private String getMoreInfoUrl(File infoDir, String toolId) {
    String moreInfoUrl = null;
    try {
        Collection<File> files = FileUtils.listFiles(infoDir, new WildcardFileFilter(toolId+"*"), null);
        if (files.isEmpty()==false) {
                for (File mFile : files) {
                    String name = mFile.getName();
                    int lastIndexOf = name.lastIndexOf('.');
                    String fNameWithOutExtension = name.substring(0,lastIndexOf);
                    if (fNameWithOutExtension.equals(toolId)) {
                        moreInfoUrl = libraryPath + mFile.getName();
                        break;
                    }

                }
        }
    } catch (Exception e) {
        log.info("unable to read moreinfo" + e.getMessage());
    }
    return moreInfoUrl;

}
项目:molgraph    文件:PsiMI25Reader.java   
/** An unit of kbase builder where the contents from 'fnames' with the 'root' are read and saved to 'out'
 *
 * @param root is the top level folder where the contents reside
 * @param out is a binary file where the graph data will be stored
 * @param fnames are the file or folder names where the source data are located.
 * @return we should return a stat object that summarize the data inventory
 */
public static PsiMI25Reader build(String out, String root, String... fnames)
{
  PsiMI25Reader interact = new PsiMI25Reader();

  if (Tools.isSet(fnames))
    for (String fname : fnames)
      // expand the file list if this is a folder
      for (String fn : IOs.listFiles(root+fname, new WildcardFileFilter("*.xml")))
      {
        System.out.println("Reading PSI-MI contents from " + fn);
        interact.parseDocument(fn);
      }

  if (Strs.isSet(out))
  {
    System.out.println("Writing the graph contents to " + out);
    interact.G.write(out);
  }
  return interact;
}
项目:ASAssets_Utilities    文件:GetServerMetadataLog.java   
public ResultCursor() {

    // get the CIS installation folder
    //
String installFolder = System.getProperty ("apps.install.dir"); 

// get the list of metadata log files from the logs folder
//
File dir = new File (installFolder + File.separatorChar + "logs");
FileFilter ff = new WildcardFileFilter ("cs_server_metadata.log*");
logFiles = dir.listFiles (ff);

// sort the list by date in ascending order
//
Arrays.sort(logFiles, new Comparator<File> () {
    public int compare (File f1, File f2) {
        return Long.valueOf(f1.lastModified()).compareTo(f2.lastModified());
    }
});
  }
项目:heroku-maven-plugin    文件:HerokuMojo.java   
protected List<File> getIncludes() {
  List<File> files = new ArrayList<File>(mIncludes.length);

  for (String s : mIncludes) {
    if (s.contains("*")) {
      String[] dirs = s.split(File.separator);
      String pattern = dirs[dirs.length-1];
      File basedir = new File(mavenProject.getBasedir(), s.replace(pattern, ""));
      Collection<File> listFiles = FileUtils.listFiles(basedir, new WildcardFileFilter(pattern), null);
      files.addAll(listFiles);
    } else {
      files.add(new File(s));
    }
  }

  return files;
}
项目:sakai    文件:SiteAction.java   
private String getMoreInfoUrl(File infoDir, String toolId) {
    String moreInfoUrl = null;
    try {
        Collection<File> files = FileUtils.listFiles(infoDir, new WildcardFileFilter(toolId+"*"), null);
        if (files.isEmpty()==false) {
                for (File mFile : files) {
                    String name = mFile.getName();
                    int lastIndexOf = name.lastIndexOf('.');
                    String fNameWithOutExtension = name.substring(0,lastIndexOf);
                    if (fNameWithOutExtension.equals(toolId)) {
                        moreInfoUrl = libraryPath + mFile.getName();
                        break;
                    }

                }
        }
    } catch (Exception e) {
        log.info("unable to read moreinfo" + e.getMessage());
    }
    return moreInfoUrl;

}
项目:testgrid    文件:TaskClientCommunicator.java   
private boolean checkResultFilesValidation(Test test, Map<String, Boolean> missingFiles) {
    File parent = new File(client.getWorkspace(), "results/" + test.getId());
    missingFiles.putAll(test.getResultFiles());
    boolean result = true;
    if (parent.exists() && parent.isDirectory()) {
        for (String f : test.getResultFiles().keySet()) {
            FileFilter fileFilter = new WildcardFileFilter(f);
            File[] fs = parent.listFiles(fileFilter);
            if (fs != null && fs.length > 0) {
                missingFiles.remove(f);
            }
        }
    }
    for (boolean r : missingFiles.values()) {
        if (r) {
            result = false;
            break;
        }
    }
    return result;
}
项目:testgrid    文件:AgentNode.java   
private boolean validateResultFiles(TestExecutor te, List<File> resultFiles, Map<String, Boolean> missingFiles) {
    Test t = te.getTest();
    boolean result = true;
    boolean isMandatory = false;
    for (String resultFile : t.getResultFiles().keySet()) {
        isMandatory = t.getResultFiles().get(resultFile);
        FileFilter fileFilter = new WildcardFileFilter(resultFile);
        File[] fs = te.getWorkspace().listFiles(fileFilter);
        if (fs != null && fs.length > 0) {
            for (File f : fs) {
                if (!resultFiles.contains(f))
                    resultFiles.add(f);
            }
        } else {
            missingFiles.put(resultFile, isMandatory);
            if (isMandatory)
                result = false;
        }

    }
    return result;
}
项目:gateplugin-StringAnnotation    文件:Tests1.java   
@BeforeClass
public static void init() throws GateException, MalformedURLException {
  if(!isInitialized) {
    System.out.println("Tests1: Inititalizing ...");
    isInitialized = true;
    Gate.runInSandbox(true);
    Gate.init();
    File pluginHome = new File(".");
    System.out.println("Plugin home directory is "+pluginHome.getAbsolutePath());
    Gate.getCreoleRegister().registerDirectories(
            pluginHome.toURI().toURL());
    testingDir = new File(pluginHome,"tests");
    assertTrue("Directory 'tests' does not exist",testingDir.exists());
    FileFilter fileFilter = new WildcardFileFilter("*.gazbin");
    File[] files = testingDir.listFiles(fileFilter);
    for(File file : files) {
      file.delete();
    }
  } else {
    System.out.println("Already initialized ...");
  }
}
项目:azkaban-plugins    文件:FileUtils.java   
/**
 * Find files while input can use wildcard * or ?
 *
 * @param filesStr File path(s) delimited by delimiter
 * @param delimiter Separator of file paths.
 * @return List of absolute path of files
 */
public static Collection<String> listFiles(String filesStr, String delimiter) {
  ValidationUtils.validateNotEmpty(filesStr, "fileStr");

  List<String> files = new ArrayList<String>();
  for (String s : filesStr.split(delimiter)) {
    File f = new File(s);
    if (!f.getName().contains("*") && !f.getName().contains("?")) {
      files.add(f.getAbsolutePath());
      continue;
    }

    FileFilter fileFilter = new AndFileFilter(new WildcardFileFilter(f.getName()), FileFileFilter.FILE);
    File parent = f.getParentFile() == null ? f : f.getParentFile();
    File[] filteredFiles = parent.listFiles(fileFilter);
    if(filteredFiles == null) {
      continue;
    }

    for (File file : filteredFiles) {
      files.add(file.getAbsolutePath());
    }
  }
  return files;
}
项目:vfs-maven-plugin    文件:VfsSync.java   
private void computeIgnoredNames(List<String> ignoredNames, List<String> notIgnoredNames) {

        Set<String> ignoredGlobPatterns = new LinkedHashSet<String>();
        for (String name : DEFAULT_IGNORED_NAMES) {
            ignoredGlobPatterns.add(name);
        }
        if (ignoredNames != null) {
            ignoredGlobPatterns.addAll(ignoredNames);
        }
        if (notIgnoredNames != null) {
            ignoredGlobPatterns.removeAll(notIgnoredNames);
        }

        debugReport("VfsSync configuration. Ignored filename patterns: " + ignoredGlobPatterns);

        this.ignoredFilesFilter = new WildcardFileFilter(new ArrayList(ignoredGlobPatterns));
    }
项目:openreportsv2    文件:ReportProviderImpl.java   
public ReportTemplate getReportTemplate(String templateName) throws ProviderException
{       
    File reportDirectory = new File(directoryProvider.getReportDirectory());        
    FileFilter templateFilter = new WildcardFileFilter(templateName + "*");
    File[] templateFiles = reportDirectory.listFiles(templateFilter);

    String[] revisions = new String[templateFiles.length];
    for (int i=0; i <  templateFiles.length; i++)
    {
        revisions[i] = templateFiles[i].getName();
    }

    Arrays.sort(revisions);

    ReportTemplate template = new ReportTemplate(templateName);
    template.setRevisions(revisions);        

    return template;
}
项目:basicworkflows    文件:basicworkflowsTestIT.java   
/**
 * Check if FSM is valid
 */
@Test
public void testisFSMValid() {
    try {
        File directory = new File("target");
        Collection files = FileUtils.listFiles(directory, new WildcardFileFilter("*.fsm"), null);
        assertTrue("FSM doesn't contain any files",files.iterator().hasNext());
        if(files.iterator().hasNext()) {
            ZipFile _fsmZip = new ZipFile((File) files.iterator().next());
            ZipEntry fsmEntry = _fsmZip.getEntry(MODULE_DESCRIPTOR);
            assertNotNull("Couldn't find module descriptor (module.xml) in fsm file",fsmEntry);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:mobile-store    文件:InstallerService.java   
@Override
protected void onHandleIntent(Intent intent) {
    final Apk apk = intent.getParcelableExtra(Installer.EXTRA_APK);
    if (apk == null) {
        Utils.debugLog(TAG, "ignoring intent with null EXTRA_APK: " + intent);
        return;
    }
    Installer installer = InstallerFactory.create(this, apk);

    if (ACTION_INSTALL.equals(intent.getAction())) {
        Uri uri = intent.getData();
        Uri downloadUri = intent.getParcelableExtra(Installer.EXTRA_DOWNLOAD_URI);
        installer.installPackage(uri, downloadUri);
    } else if (ACTION_UNINSTALL.equals(intent.getAction())) {
        installer.uninstallPackage();
        new Thread() {
            @Override
            public void run() {
                setPriority(MIN_PRIORITY);
                File mainObbFile = apk.getMainObbFile();
                if (mainObbFile == null) {
                    return;
                }
                File obbDir = mainObbFile.getParentFile();
                if (obbDir == null) {
                    return;
                }
                FileFilter filter = new WildcardFileFilter("*.obb");
                File[] obbFiles = obbDir.listFiles(filter);
                if (obbFiles == null) {
                    return;
                }
                for (File f : obbFiles) {
                    Utils.debugLog(TAG, "Uninstalling OBB " + f);
                    FileUtils.deleteQuietly(f);
                }
            }
        }.start();
    }
}
项目:opentest    文件:ListFiles.java   
@Override
public void run() {
    super.run();

    String directoryPath = readStringArgument("directory");
    String pattern = readStringArgument("pattern", "*");
    // Some valid orderBy values: "date", "date, desc", "name", "size"
    String orderBy = readStringArgument("orderBy", "name");

    List<File> files;
    File directory = new File(directoryPath);
    if (directory.exists()) {
        FileFilter fileFilter = new WildcardFileFilter(pattern);
        files = Arrays.asList(directory.listFiles(fileFilter));
    } else {
        log.warning(String.format("Directory \"%s\" doesn't exist", directoryPath));
        files = new ArrayList<File>(0);
    }

    if (orderBy != null) {
        if (orderBy.matches("^\\s*date.*")) {
            files = files.stream().sorted(Comparator.comparing(File::lastModified)).collect(Collectors.toList());
        } else if (orderBy.matches("^\\s*name.*")) {
            files = files.stream().sorted(Comparator.comparing(File::getName)).collect(Collectors.toList());
        } else if (orderBy.matches("^\\s*size.*")) {
            files = files.stream().sorted(Comparator.comparing(File::length)).collect(Collectors.toList());
        }

        if (orderBy.matches(".*,\\s*desc\\s*$")) {
            Collections.reverse(files);
        }
    }

    this.writeOutput("files", files);
    if (files.size() > 0) {
        this.writeOutput("firstFile", files.size() > 0 ? files.get(0) : null);
        this.writeOutput("lastFile", files.size() > 0 ? files.get(files.size() - 1) : null);
    }
}
项目:ChronoBike    文件:MaskFileFilter.java   
void add(String csMask)
{
    if(csMask != null)
    {
        if(m_arrMaskFilters == null)
            m_arrMaskFilters = new ArrayList<FileFilter>();

        csMask = csMask.trim();
        FileFilter fileFilter = new WildcardFileFilter(csMask);
        m_arrMaskFilters.add(fileFilter);
    }
}
项目:yajsw    文件:FileUtils.java   
/**
 * Gets the wildcard files.
 * 
 * @param path
 *            the path
 * @param file
 *            the file
 * 
 * @return the wildcard files
 */
private static Collection getWildcardFiles(String path, String file)
{
    ArrayList result = new ArrayList();
    File fPath = new File(path);
    try
    {
        if (!fPath.isDirectory())
        {
            log.warning("classpath directory " + fPath.getCanonicalPath()
                    + " not found");
            return result;
        }
    }
    catch (Exception ex)
    {
        log.warning("classpath directory " + path + " error"
                + ex.getMessage());
        return result;
    }
    FileFilter fileFilter = new WildcardFileFilter(file);
    File[] thisFiles = fPath.listFiles(fileFilter);
    if (thisFiles == null)
    {
        log.warning("error accessing " + path);
        return result;
    }

    for (int i = 0; i < thisFiles.length; i++)
    {
        File f = thisFiles[i];
        if (f.exists())
            result.add(f);
        else
            log.warning("classpath file " + f.getName() + "not found");
    }
    return result;
}
项目:yajsw    文件:FileUtils.java   
/**
 * Gets the wildcard files.
 * 
 * @param path
 *            the path
 * @param file
 *            the file
 * 
 * @return the wildcard files
 */
private static Collection getWildcardFiles(String path, String file)
{
    ArrayList result = new ArrayList();
    file = file.trim();
    if (file.equals(".") || file.equals(".."))
    {
        result.add(new File(path + "/" + file));
        return result;
    }
    File fPath = new File(path);
    try
    {
        if (!fPath.isDirectory())
        {
            log.warning("classpath directory " + fPath.getCanonicalPath()
                    + " not found");
            return result;
        }
    }
    catch (Exception ex)
    {
        log.warning("classpath directory " + path + " error"
                + ex.getMessage());
        return result;
    }
    FileFilter fileFilter = new WildcardFileFilter(file);
    File[] thisFiles = fPath.listFiles(fileFilter);
    for (int i = 0; i < thisFiles.length; i++)
    {
        File f = thisFiles[i];
        if (f.exists())
            result.add(f);
        else
            log.warning("classpath file " + f.getName() + "not found");
    }
    return result;
}
项目:opennlp-enhancer    文件:ModelLoaderConfig.java   
public static String[] getModels(String[] modelNames) {
    File dir = new File(Config.getConfiguration().getString(MODELPATH));
    LOG.info("Loading Models from... " + dir.getAbsolutePath());

    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()]);
}
项目:bigstreams    文件:TestDirectoryPollingThread.java   
@Test
public void testSeeUpdatesNoUpdate() {
    // Check to see that on the second run the files are not marked as
    // updated
    // when they haven't been updated

    MapTrackerMemory memory = new MapTrackerMemory();

    DirectoryPollingThread dpth = new DirectoryPollingThread("test1",
            new SimpleFileDateExtractor(),
            memory);
    dpth.setDirectory(createFilesDir.getAbsolutePath());
    dpth.setFileFilter(new WildcardFileFilter("*.log"));

    // set the memory see the files as new first
    dpth.run();

    assertEquals(newFilesArr.length, memory.getFileCount());

    // run again to make sure no updates are registered on the second run
    dpth.run();

    for (File file : newFilesArr) {
        assertNotNull(memory.getFileStatus(file));

        assertEquals(FileTrackingStatus.STATUS.READY,
                memory.getFileStatus(file).getStatus());
    }

}
项目:neural-style-gui    文件:FileUtils.java   
public static Map<String, Set<String>> getTempOutputs() {
    Map<String, Set<String>> outputs = new LinkedHashMap<>();

    File[] styleFiles = getTempOutputStyles();

    if (styleFiles == null)
        return outputs;

    for (File styleFile : styleFiles) {
        Set<String> imageFilesList = new LinkedHashSet<>();

        // Unix-like searching for images
        FileFilter imageFileFilter = new WildcardFileFilter(String.format("%s_*.png", getFileName(styleFile)));
        File[] imageFiles = tempDir.listFiles(imageFileFilter);

        if (imageFiles != null && imageFiles.length > 1) {
            int[] imageFileIters = new int[imageFiles.length];
            for (int i = 0; i < imageFiles.length; i++)
                imageFileIters[i] = FileUtils.parseImageIteration(imageFiles[i]);
            FileUtils.quickSort(imageFileIters, imageFiles, 0, imageFiles.length - 1);

            // if the latest file was still being written to during the check
            // then replace it with the previous file (set will remove it)
            if (isFileBeingWritten(imageFiles[imageFiles.length - 1]))
                imageFiles[imageFiles.length - 1] = imageFiles[imageFiles.length - 2];

            for (File imageFile : imageFiles)
                imageFilesList.add(imageFile.getAbsolutePath());
        }

        outputs.put(styleFile.getAbsolutePath(), imageFilesList);
    }

    return outputs;
}
项目:TranskribusCore    文件:LocalFimagestoreClient.java   
public static File getFile(File dir, String fileType) throws FileNotFoundException {
        if (fileType.equals(FILE_TYPE_METADATA))
            return getMetadataFile(dir);

//      FileMetadata metadata = MetadataParser.parseMetadata(dir);
//      
//      // if fileType = browser and original file is browser compatible then return original file:
//      if (fileType.equals(FImagestoreVars.FILE_TYPE_BROWSER) && 
//              MimeTypes.isImageMimeTypeBrowserCompatible(metadata.Mimetype)) {
////            return getOrigFile(dir);
//          fileType=FImagestoreVars.FILE_TYPE_ORIG;
//      }
//      // else if fileType = view and original file is binarized then return original file:
//      if (fileType.equals(ImagestoreVars.FILE_TYPE_VIEW) && metadata.imgMetadata.NComponents==1) {
//          return getOrigFile(dir);
//      }

        // else: get file of type fileType:
//      List<File> files = (List<File>) FileUtils.listFiles(dir, new WildcardFilter(fileType+"_*.*"), null);
        List<File> files = (List<File>) FileUtils.listFiles(dir, new WildcardFileFilter(fileType+"_*.*"), null);

        if (files.size()==0)
            throw new FileNotFoundException("File of type "+fileType+" not found in dir: "+dir.getAbsolutePath());
        else if (files.size()>1)
            throw new FileNotFoundException("File of type "+fileType+" is duplicate in dir: "+dir.getAbsolutePath());
        else
            return files.get(0);
    }
项目:ModPackDownloader    文件:ModpackDownloaderCLITest.java   
@Test
public void testAppUpdate() throws InterruptedException {
    String[] args = {"-updateApp"};
    ModpackDownloaderCLI.main(args);
    FileFilter fileFilter = new WildcardFileFilter("ModpackDownloader*jar");
    File directory = new File(".");
    List<File> files = Arrays.asList(directory.listFiles(fileFilter));
    Assert.assertTrue(!CollectionUtils.isEmpty(files));
    files.forEach(File::deleteOnExit);
}