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

项目:mdetect    文件:FileScanUtils.java   
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;
}
项目:isetools    文件:Command.java   
/**
 * Get a list of file paths from the command line arguments.
 *
 * @param cmd Parsed command line arguments.
 * @return File[]
 */
public File[] getFilePaths(CommandLine cmd) {
  Collection<File> fileList = new ArrayList<>();

  List<?> argList = cmd.getArgList();
  argList = argList.subList(1, argList.size());
  String[] args = argList.toArray(new String[argList.size()]);

  if (argList.isEmpty()) {
    File dir = new File("input");
    SuffixFileFilter sfx = new SuffixFileFilter(".txt");
    fileList = FileUtils.listFiles(dir, sfx, TrueFileFilter.INSTANCE);
  } else {
    for (String name : args) {
      fileList.add(new File(name));
    }
  }

  File[] files = fileList.toArray(new File[fileList.size()]);
  Arrays.sort(files);
  return files;
}
项目:dawg    文件:RemotePluginManager.java   
/**
 * When the server starts up it will reload all the plugins back in
 * @throws IOException
 */
@PostConstruct
public void loadPlugins() throws IOException {
    File pluginsDir = new File(config.getPluginDir());
    if (!pluginsDir.exists()) {
        pluginsDir.mkdirs();
    }
    if (pluginsDir.exists()) {
        FilenameFilter jarSuffix = new SuffixFileFilter(".jar");
        File[] files = pluginsDir.listFiles(jarSuffix);
        for (File file : files) {
            storePlugin(file);
        }
    } else {
        LOGGER.warn("Plugins directory does not exist '" + pluginsDir.getAbsolutePath() + "'");
    }
}
项目:cleartk    文件:DescriptorTestUtil.java   
public static void testNoDescriptorsInSrc(String srcDirectoryName) {
  // collect the names of all .xml descriptors in the src directory
  File srcDirectory = new File(srcDirectoryName);
  Set<String> descNames = new HashSet<String>();
  Iterator<?> files = org.apache.commons.io.FileUtils.iterateFiles(
      srcDirectory,
      new SuffixFileFilter(".xml"),
      TrueFileFilter.INSTANCE);
  while (files.hasNext()) {
    File file = (File) files.next();
    descNames.add(file.getPath());
  }

  if (descNames.size() > 0) {
    String message = String.format("%d descriptors in src/main/java", descNames.size());
    System.err.println(message);
    List<String> sortedFileNames = new ArrayList<String>(descNames);
    Collections.sort(sortedFileNames);
    for (String name : sortedFileNames) {
      System.err.println(name);
    }
    Assert.fail(message);
  }

}
项目:motech    文件:OsgiFrameworkService.java   
/**
 * Find external/optional bundles from the ~/.motech/bundles directory.
 * Additional modules come from that directory, additionally platform bundles
 * can be override,
 */
private Map<BundleID, URL> findExternalBundles() throws IOException {
    Map<BundleID, URL> externalBundles = new HashMap<>();
    if (StringUtils.isNotBlank(externalBundleFolder)) {
        File folder = new File(externalBundleFolder);
        boolean exists = folder.exists();

        if (!exists) {
            exists = folder.mkdirs();
        }

        if (exists) {
            File[] files = folder.listFiles((FileFilter) new SuffixFileFilter(".jar"));
            URL[] urls = FileUtils.toURLs(files);

            for (URL url : urls) {
                BundleID bundleID = bundleIdFromURL(url);
                if (bundleID != null) {
                    externalBundles.put(bundleID, url);
                }
            }
        }
    }

    return externalBundles;
}
项目:appengine-imaging    文件:MagicNumbersTest.java   
@Test
public void test() throws IOException {
    List<String> imageSuffixes = Lists.newArrayList();
    for (ImageInfo.Format format : ImageInfo.Format.values()) {
        for (String ext : format.getCommonExtensions()) {
            imageSuffixes.add("." + ext);
        }
    }
    SuffixFileFilter filter = new SuffixFileFilter(imageSuffixes);
    List<File> files = TestData.getFiles(filter);
    for (File file : files) {
        byte[] bytes = Files.toByteArray(file);
        BytePair magic = MagicNumbers.read(bytes);
        System.out.format("%s %s%n", magic, file.getName());
    }
}
项目:kfs    文件:AssetBarcodeInventoryInputFileType.java   
/**
 * 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;
}
项目:sagetv-phoenix-core    文件:VFSManager.java   
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);
}
项目:netxilia    文件:DynamicClassLoader.java   
public DynamicClassLoader() {
    try {
        File home = new File(System.getProperty("user.home"), "netxilia");
        if (!home.exists()) {
            if (!home.mkdir()) {
                log.error("Could not create Netxilia storage directory:" + home);
                return;
            }
        }
        addFile(home);
        for (File jar : home.listFiles((FilenameFilter) new SuffixFileFilter(".jar"))) {
            addFile(jar);
        }
    } catch (IOException e) {
        log.error("ERROR:" + e);
    }

}
项目:opensearchserver    文件:AutoCompletionManager.java   
public AutoCompletionManager(Config config) throws SearchLibException,
        IOException {
    this.config = config;
    autoCompletionDirectory = new File(config.getDirectory(),
            autoCompletionSubDirectory);
    if (!autoCompletionDirectory.exists())
        autoCompletionDirectory.mkdir();
    autoCompItems = new TreeSet<AutoCompletionItem>();
    File[] autoCompFiles = autoCompletionDirectory
            .listFiles((FileFilter) new SuffixFileFilter(".xml"));
    if (autoCompFiles == null)
        return;
    for (File autoCompFile : autoCompFiles) {
        try {
            add(new AutoCompletionItem(config, autoCompFile));
        } catch (InvalidPropertiesFormatException e) {
            Logging.warn("Invalid autocompletion file: "
                    + autoCompFile.getAbsolutePath());
        }
    }
}
项目:parkingfriends    文件:LiquibaseReloader.java   
/**
 * Calculate the next sequence used to generate the db-changelog file.
 *
 * The sequence is formatted as follow:
 *    leftpad with 0 + number
 * @return the next sequence
 */
private String calculateNextSequence() {
    final File changeLogFolder = FileSystems.getDefault().getPath(CHANGELOG_FOLER).toFile();

    final File[] allChangelogs = changeLogFolder.listFiles((FileFilter) new SuffixFileFilter(".xml"));

    Integer sequence = 0;

    for (File changelog : allChangelogs) {
        String fileName = FilenameUtils.getBaseName(changelog.getName());
        String currentSequence = StringUtils.substringAfterLast(fileName, "-");
        int cpt = Integer.parseInt(currentSequence);
        if (cpt > sequence) {
            sequence = cpt;
        }
    }
    sequence++;
    return StringUtils.leftPad(sequence.toString(), 3, "0");
}
项目:Reinickendorf_SER316    文件:AgendaPanel.java   
/**
 * Scans sub directories associated with the target 'src' folder, lists them into dirsList
 * @throws IOException 
 * 
 */
public static synchronized void scanDirectoriesAtFolderChosen(JFileChooser jfc, Path dir, ConcurrentHashMap<String, String> holdValueToKey, WatchService watcher) throws IOException{//JFileChooser jfc, Path dir
    File f = new File(jfc.getSelectedFile().getAbsolutePath());
    if(f.isDirectory()){
    //System.out.println("Is a directory: "+jfc.getSelectedFile().getAbsolutePath());

    File rFile = new File(jfc.getSelectedFile().getAbsolutePath());
    SuffixFileFilter extFilter = new SuffixFileFilter("java");
    Collection filesListUtil = FileUtils.listFilesAndDirs(rFile,extFilter,TrueFileFilter.INSTANCE); //get utils for files in subdir, looks for .java files as well
    ArrayList<File> filesList = new ArrayList<File>();
    ArrayList<File> dirsList = new ArrayList<File>();

    for(java.util.Iterator fileIter = filesListUtil.iterator();fileIter.hasNext();){    //iterate through filesListUtil subdirs, add to filesList to be watched
        File currentF = (File) fileIter.next();
        //System.out.println("Reading Paths from: "+currentF.getAbsolutePath());
        if(!(currentF.isDirectory())){
            filesList.add(currentF);    //add each file while iterating through subdirectories
        }else{
            dirsList.add(currentF); //add each dir to watch
        }
    }


    /**
    * File system traversal
    */

    System.out.println("WatchService: DirectoriesList length = "+dirsList.size());
    //System.out.println("FilesListUtil length: "+filesListUtil.size());
    fileSystemTraversal(dirsList, dir, watcher, holdValueToKey);

    }
}
项目:confucius-commons    文件:ClassUtils.java   
protected static Set<String> findClassNamesInDirectory(File classesDirectory, boolean recursive) {
    Set<String> classNames = Sets.newLinkedHashSet();
    SimpleFileScanner simpleFileScanner = SimpleFileScanner.INSTANCE;
    Set<File> classFiles = simpleFileScanner.scan(classesDirectory, recursive, new SuffixFileFilter(FileSuffixConstants.CLASS));
    for (File classFile : classFiles) {
        String className = resolveClassName(classesDirectory, classFile);
        classNames.add(className);
    }
    return classNames;
}
项目:gdx-texture-packer-gui    文件:LoggerUtils.java   
public static void setupExternalFileOutput() {
    try {
        Date currentDate = new Date();
        long currentTime = currentDate.getTime();
        String fileName = new SimpleDateFormat("yyMMddhhmm").format(currentDate) + ".log";
        File logFile = new File(LwjglFiles.externalPath + AppConstants.LOGS_DIR + File.separator + fileName);
        logFile.getParentFile().mkdirs();
        for (File oldLogFile : logFile.getParentFile().listFiles((FileFilter)new SuffixFileFilter(LOG_FILE_EXTENSION))) {
            long lastModified = oldLogFile.lastModified();
            if (currentTime - lastModified > EXPIRATION_THRESHOLD) {
                try { oldLogFile.delete(); } catch (SecurityException ignored) { }
            }
        }
        FileOutputStream logFileOutputStream = new FileOutputStream(logFile);
        System.setOut(new PrintStream(new OutputStreamMultiplexer(
                new FileOutputStream(FileDescriptor.out),
                logFileOutputStream
        )));
        System.setErr(new PrintStream(new OutputStreamMultiplexer(
                new FileOutputStream(FileDescriptor.err),
                logFileOutputStream
        )));
        System.out.println("Version: " + AppConstants.version);
        System.out.println("OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch"));
        System.out.println("JRE: " + System.getProperty("java.version") + " " + System.getProperty("java.vendor"));
        System.out.println("External log file: " + logFile.getAbsolutePath());
    } catch (FileNotFoundException e) {
        System.err.println("Can't setup logging to external file.");
        e.printStackTrace();
    }
}
项目:project-build-plugin    文件:EngineClassLoaderFactory.java   
public static List<File> getOsgiBootstrapClasspath(File engineDirectory)
{
  if (engineDirectory == null || !engineDirectory.isDirectory())
  {
    return Collections.emptyList();
  }
  List<File> classPathFiles = new ArrayList<>();
  addToClassPath(classPathFiles, new File(engineDirectory, OsgiDir.INSTALL_AREA + "/" + OsgiDir.LIB_BOOT), new SuffixFileFilter(".jar"));
  return classPathFiles;
}
项目:me3modmanager    文件:TLKTool.java   
private static void compileTLK(String path) throws IOException, InterruptedException {
    File dir = new File(path);
    System.out.println(dir);
    Collection<File> files = FileUtils.listFiles(dir, new SuffixFileFilter(".xml"), FalseFileFilter.FALSE);
    for (File file : files) {
        System.out.println(file.getAbsolutePath());
    }

    for (File f : files) {
        ArrayList<String> commandBuilder = new ArrayList<String>();

        String compilerPath = ModManager.getTankMasterTLKDir() + "MassEffect3.TlkEditor.exe";
        commandBuilder.add(compilerPath);
        commandBuilder.add(f.getAbsolutePath());
        commandBuilder.add(f.getParent() + File.separator + FilenameUtils.getBaseName(f.getAbsolutePath()) + ".xml");
        commandBuilder.add("--mode");
        commandBuilder.add("ToTlk");
        commandBuilder.add("--no-ui");
        String[] command = commandBuilder.toArray(new String[commandBuilder.size()]);
        //Debug stuff
        StringBuilder sb = new StringBuilder();
        for (String arg : command) {
            sb.append(arg + " ");
        }
        Process p = null;
        System.out.println("Executing: " + sb.toString());
        ProcessBuilder pb = new ProcessBuilder(command);
        pb.redirectErrorStream(true);
        p = pb.start();
        p.waitFor();
    }
}
项目:l10n-maven-plugin    文件:DirectoryValidator.java   
/**
 * Load a group of Properties file from a directory
 */
protected int loadPropertiesFamily(File directory, List<L10nReportItem> reportItems,
    List<PropertiesFamily> propertiesFamilies) {
  int nbErrors = 0;

  logger.getLogger().info("Looking for .properties files in: " + directory.getAbsolutePath());
  List<PropertiesFile> propertiesFilesInDir = new ArrayList<PropertiesFile>();
  Collection<File> files = Collections.emptyList();

  if (directory.exists()) {
    files = FileUtils.listFiles(directory, new SuffixFileFilter(".properties"), TrueFileFilter.INSTANCE);
  }
  if (files == null || files.size() == 0) {
    logger.getLogger().warn(
        "No properties file under folder " + directory.getAbsolutePath() + ". Skipping l10n validation.");

  } else {
    for (File file : files) {
      // Validate File
      nbErrors += duplicateKeysValidator.validate(file, reportItems);

      // Load it normally
      propertiesFilesInDir.add(loadPropertiesFile(file, directory, reportItems));
    }
  }
  propertiesFamilies.addAll(loadPropertiesFamily(propertiesFilesInDir));
  return nbErrors;
}
项目:l10n-maven-plugin    文件:SpellCheckValidator.java   
/**
 * Initialize by loading dictionaries following {@link Locale} naming convention
 * 
 * @param logger
 * @param directory
 *          dictionaries location
 */
public SpellCheckValidator(L10nValidatorLogger logger, File directory) {
  super(logger);
  spellCheckerLocaleRepository = new LocaleTreeSpellCheckerRepository(logger);

  if (directory != null) {
    logger.getLogger().info("Looking for .dic files in: " + directory.getAbsolutePath());
    File[] files = directory.listFiles((FilenameFilter) new SuffixFileFilter(".dic"));
    if (files == null || files.length == 0) {
      logger.getLogger().warn("No dictionary file under folder " + directory.getAbsolutePath() + ". Skipping spellcheck validation.");

    } else {
      // Load each dictionary, using file name to detect associated locale
      for (File file : files) {
        try {
          String fileName = FilenameUtils.getBaseName(file.getName());
          String localePart = null;
          String[] parts = fileName.split("_", 2);
          if (parts[0].length() == 2) {
            localePart = fileName;
          } else if (parts.length == 2) {
            localePart = parts[1];
          }
          Locale locale = PropertiesFileUtils.getLocale(localePart);
          logger.getLogger().info("Loading file <" + file.getName() + "> associated to locale <" + locale + ">");

          SpellDictionary dictionary = new SpellDictionaryHashMap(file);
          spellCheckerLocaleRepository.addDictionary(locale, dictionary);

        } catch (IOException e) {
          logger.getLogger().error(e);
        }
      }
    }
  } else {
    logger.getLogger().warn("No dictionary folder provided, skipping spellcheck validation.");
  }
}
项目:tibco-codereview    文件:BWProjectBuilder.java   
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]));
}
项目:demyo    文件:ImageService.java   
@Override
@Transactional(readOnly = true)
public List<String> findUnknownDiskImages() {
    List<String> unknownFiles = new ArrayList<>();
    File imagesDirectory = SystemConfiguration.getInstance().getImagesDirectory();

    // Find the files
    Collection<File> foundFiles = FileUtils.listFiles(imagesDirectory,
            new SuffixFileFilter(Arrays.asList(".jpg", ".jpeg", ".png", ".gif"), IOCase.INSENSITIVE),
            TrueFileFilter.INSTANCE);

    // Find the paths known in the database
    Set<String> knownFiles = repo.findAllPaths();

    // Filter out the known files
    Path imagesDirectoryPath = imagesDirectory.toPath();
    LOGGER.trace("Known files: {}", knownFiles);
    for (File file : foundFiles) {
        String relativePath = imagesDirectoryPath.relativize(file.toPath()).toString();
        // Normalize file separators so that collections imported and exported between OS's still work
        relativePath = relativePath.replace(File.separatorChar, '/');
        boolean known = knownFiles.contains(relativePath);
        LOGGER.trace("Is {} known? {}", relativePath, known);

        if (!known) {
            unknownFiles.add(relativePath);
        }
    }

    Collections.sort(unknownFiles);

    return unknownFiles;
}
项目:artifactory    文件:MimeTypesReaderTest.java   
public void versionsRead() {
    File versionsDirectory = ResourceUtils.getResourceAsFile(
            "/org/artifactory/mime/version/mimetypes-v1.xml").getParentFile();
    File[] mimeTypeFiles = versionsDirectory.listFiles((FileFilter) new SuffixFileFilter("xml"));
    assertTrue(mimeTypeFiles.length > 0, "Couldn't find mime types files under "
            + versionsDirectory.getAbsolutePath());
    for (File mimeTypeFile : mimeTypeFiles) {
        MimeTypesReader reader = new MimeTypesReader();
        reader.read(mimeTypeFile);  // will throw an exception on error
    }
}
项目:artifactory    文件:PassThroughMetadataReaderImpl.java   
@Override
public List<MetadataEntryInfo> getMetadataEntries(File file, MutableStatusHolder status) {
    if (!file.isDirectory()) {
        status.error("Expecting a directory but got file: " + file.getAbsolutePath(), log);
        return Collections.emptyList();
    }

    String[] metadataFileNames = file.list(new SuffixFileFilter(".xml"));
    if (metadataFileNames == null) {
        status.error("Cannot read list of metadata files from " + file.getAbsolutePath() + ": "
                + Files.readFailReason(file), log);
        return Collections.emptyList();
    }

    //Import all the xml files within the metadata folder
    List<MetadataEntryInfo> result = Lists.newArrayListWithCapacity(metadataFileNames.length);
    for (String metadataFileName : metadataFileNames) {
        File metadataFile = new File(file, metadataFileName);
        String extension = PathUtils.getExtension(metadataFileName);
        if (!verify(status, metadataFileName, metadataFile, extension)) {
            continue;
        }
        status.debug("Importing metadata from '" + metadataFile.getPath() + "'.", log);

        try {
            // metadata name is the name of the file without the extension
            String metadataName = PathUtils.stripExtension(metadataFileName);
            String xmlContent = FileUtils.readFileToString(metadataFile, "utf-8");
            MetadataEntryInfo metadataEntry = createMetadataEntry(metadataName, xmlContent);
            result.add(metadataEntry);
        } catch (Exception e) {
            status.error("Failed to import xml metadata from '" +
                    metadataFile.getAbsolutePath() + "'.", e, log);
        }
    }
    return result;
}
项目:springmvc-raml-plugin    文件:ClassLoaderUtils.java   
public static List<String> loadClasses(MavenProject mavenProject) throws MojoExecutionException {

        List<String> classes = Lists.newArrayList();

        File rootDir = new File(mavenProject.getBuild().getSourceDirectory());
        Collection<File> files = FileUtils.listFiles(rootDir, new SuffixFileFilter(".java"), TrueFileFilter.TRUE);
        for (File file : files) {
            String clazz = file.getName().replace(".java", "");
            if (!clazz.isEmpty()) {
                classes.add(clazz);
            }
        }
        return classes;
    }
项目:cleartk    文件:ParametersTestUtil.java   
public static void testParameterDefinitions(String outputDirectory, String... excludeFiles)
    throws ClassNotFoundException {
  IOFileFilter includeFilter = new SuffixFileFilter(".java");

  if (excludeFiles != null) {
    IOFileFilter excludeFilter = FileFilterUtils.notFileFilter(new SuffixFileFilter(excludeFiles));
    includeFilter = FileFilterUtils.and(excludeFilter, includeFilter);
  }

  Iterator<File> files = org.apache.commons.io.FileUtils.iterateFiles(
      new File(outputDirectory),
      includeFilter,
      TrueFileFilter.INSTANCE);
  testParameterDefinitions(files);
}
项目:cleartk    文件:LicenseTestUtil.java   
public static void testDescriptorFiles(String directoryName) throws IOException {
  List<String> filesMissingLicense = new ArrayList<String>();

  File directory = new File(directoryName);
  Iterator<?> files = org.apache.commons.io.FileUtils.iterateFiles(
      directory,
      new SuffixFileFilter(".xml"),
      TrueFileFilter.INSTANCE);

  while (files.hasNext()) {
    File file = (File) files.next();
    String fileText = FileUtils.file2String(file);

    if (fileText.indexOf("Copyright (c) ") == -1
        || fileText.indexOf("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"") == -1) {

      if (file.getName().equals("GENIAcorpus3.02.articleA.pos.xml"))
        continue;
      if (file.getParent().equals("src/org/cleartk/descriptor".replace('/', File.separatorChar)))
        continue;
      filesMissingLicense.add(file.getPath());
    }
  }

  if (filesMissingLicense.size() > 0) {
    String message = String.format(
        "%d descriptor files with no license. ",
        filesMissingLicense.size());
    System.err.println(message);
    Collections.sort(filesMissingLicense);
    for (String path : filesMissingLicense) {
      System.err.println(path);
    }
    Assert.fail(message);
  }
}
项目:cleartk    文件:LineReader.java   
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
  try {
    this.rootFile = new File(fileOrDirectoryName);

    // raise an exception if the root file does not exist
    if (!this.rootFile.exists()) {
      String format = "file or directory %s does not exist";
      String message = String.format(format, fileOrDirectoryName);
      throw new ResourceInitializationException(new IOException(message));
    }

    if (rootFile.isDirectory()) {
      if (suffixes != null && suffixes.length > 0) {
        files = FileUtils.iterateFiles(
            rootFile,
            new SuffixFileFilter(suffixes),
            TrueFileFilter.INSTANCE);
      } else {
        files = FileUtils.iterateFiles(rootFile, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
      }
    } else {
      files = Arrays.asList(rootFile).iterator();
    }
    if (commentSpecifiers == null) {
      commentSpecifiers = new String[0];
    }

    lineHandler = InitializableFactory.create(
        getUimaContext(),
        lineHandlerClassName,
        LineHandler.class);
    moveToNextFile();
  } catch (Exception fnfe) {
    throw new ResourceInitializationException(fnfe);
  }
}
项目:Java-RSRepair    文件:ContextFactory.java   
/**
 * Generates a list of java source files given a directory, or returns the
 * file specified in an array.
 * @param sourcePaths The path to the file/directory.
 * @return An array of paths to Java source files.
 * @throws Exception
 */
private static String[] getSourceFiles(String[] sourcePaths) throws Exception{
    Collection<File> sourceFiles = new LinkedList<File>();
    String[] sourceFilesArray = null;

    for(String sourcePath : sourcePaths){
        File sourceFile = new File(sourcePath);

           /* If the buggy file is a directory, get all the java files in that directory. */
           if(sourceFile.isDirectory()){
               sourceFiles.addAll(FileUtils.listFiles(sourceFile, new SuffixFileFilter(".java"), TrueFileFilter.INSTANCE));
           }
           /* The buggy file may also be a source code file. */
           else{
               sourceFiles.add(sourceFile);
           }

           /* Create the String array. */
           sourceFilesArray = new String[sourceFiles.size()];
           int i = 0;
           for(File file : sourceFiles){
               sourceFilesArray[i] = file.getCanonicalPath();
               i++;
           }
    }

    return sourceFilesArray;
}
项目:TtorrentAndroid    文件:TrackerMain.java   
private static void addAnnounce(Tracker tracker, File file, int depth) throws IOException, URISyntaxException {
    if (file.isFile()) {
        logger.info("Loading torrent from " + file.getName());
        Torrent torrent = new Torrent(file);
        tracker.announce(new TrackedTorrent(torrent.getName(), torrent.getInfoHash()));
        return;
    }
    if (depth > 3)
        return;
    FilenameFilter filter = new SuffixFileFilter(".torrent");
    for (File child : file.listFiles(filter))
        addAnnounce(tracker, child, depth + 1);
}
项目:OLE-INST    文件:ReportAggregationStep.java   
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;
}
项目:OLE-INST    文件:EnterpriseFeederFileSetType.java   
/**
 * 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;
}
项目:OLE-INST    文件:CorrectionDocumentServiceImpl.java   
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 ;
}
项目:maven-repository-tools    文件:MavenRepositoryDeployer.java   
public static Collection<File> getPomFiles( File repoPath )
{
    Collection<File> pomFiles = new ArrayList<File>();
    Collection<File> leafDirectories = getLeafDirectories( repoPath );
    for ( File leafDirectory : leafDirectories )
    {
        IOFileFilter fileFilter = new AndFileFilter( new WildcardFileFilter( "*.pom" ),
                                           new NotFileFilter( new SuffixFileFilter( "sha1" ) ) );
        pomFiles.addAll( FileUtils.listFiles( leafDirectory, fileFilter, null ) );
    }
    return pomFiles;
}
项目:vdoc-maven-plugin    文件:DeployVDocMojo.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    this.pluginDescriptor = ((PluginDescriptor) getPluginContext().get("pluginDescriptor"));

    if (this.mavenHome == null )
    {
        String mavenEnv = System.getenv("M2_HOME");
        Validate.notEmpty(mavenEnv, "M2_HOME is not set you can used the maven-home configuration!");
        mavenHome = new File(mavenEnv);
    }

    if (!mavenHome.exists() )
    {
        throw new IllegalArgumentException("maven home (M2_HOME or maven-home configuration) is set to bad location : " + mavenHome.getAbsolutePath());
    }

    OrFileFilter prefixFileFilter = new OrFileFilter();
    prefixFileFilter.addFileFilter(new PrefixFileFilter("VDoc"));
    prefixFileFilter.addFileFilter(new PrefixFileFilter("VDP"));

    AndFileFilter fileFilter = new AndFileFilter();
    fileFilter.addFileFilter(prefixFileFilter);
    fileFilter.addFileFilter(new SuffixFileFilter(".jar"));

    File[] earFiles = earFolder.listFiles((FileFilter) fileFilter);
    getLog().info("Scan the vdoc.ear folder");
    deployFiles(earFiles);
    getLog().info("Scan the vdoc.ear/lib folder");
    File[] earLibFiles = new File(earFolder, "lib").listFiles((FileFilter) fileFilter);
    deployFiles(earLibFiles);

    buildParentPom("sdk");
    buildParentPom("sdk.advanced");

}
项目:Leo    文件:FileCollectionReaderTest.java   
@Test
public void testGetNext() throws Exception {
    FileCollectionReader fsr =
            (FileCollectionReader) new FileCollectionReader(new File(rootDirectory + "src/test/resources/inputDirectory"), true)
                    .setEncoding(Charset.defaultCharset().displayName())
                    .setRecurseFlag(false)
                    .produceCollectionReader();
    assertNotNull(fsr);
    assertEquals(Charset.defaultCharset().displayName(), fsr.getEncoding());
    assertEquals(new File(rootDirectory + "src/test/resources/inputDirectory").getAbsolutePath(), fsr.getInputDirectory().getAbsolutePath());
    FilenameFilter filenameFilter = fsr.getFilenameFilter();
    assertTrue(filenameFilter instanceof SuffixFileFilter);
    assertFalse(fsr.mRecurse);

    AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(SampleService
            .simpleServiceDefinition()
            .getAnalysisEngineDescription());
    CAS mockCas = ae.newCAS();
    assertTrue(fsr.hasNext());
    fsr.getNext(mockCas);
    assertEquals(1, fsr.getCurrentIndex());
    FSIterator<AnnotationFS> csiIterator = mockCas.getAnnotationIndex(mockCas.getTypeSystem().getType(CSI.class.getCanonicalName())).iterator();
    assertTrue(csiIterator.hasNext());
    CSI csi = (CSI) csiIterator.next();
    assertTrue("text1.txt".equals(csi.getID()));
    //System.out.println(csi.getLocator());
    assertTrue(csi.getLocator().endsWith("client/src/test/resources/inputDirectory/text1.txt"));
    assertNull(csi.getPropertiesKeys());
    assertNull(csi.getRowData());
    assertTrue(RESULTS.equals(mockCas.getDocumentText()));
}
项目:kfs    文件:ReportAggregationStep.java   
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;
}
项目:kfs    文件:EnterpriseFeederFileSetType.java   
/**
 * 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 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;
}
项目:kfs    文件:CorrectionDocumentServiceImpl.java   
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 ;
}
项目:sagetv-phoenix-core    文件:MetadataManager.java   
public MetadataManager(File systemDir, File userDir) {
    super(systemDir, userDir, new SuffixFileFilter(".xml", IOCase.INSENSITIVE));

    this.dtd = new File(systemDir, "metadata.dtd");
    dtdResolver = new EntityResolver() {
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            return new InputSource(new FileInputStream(dtd));
        }
    };
}
项目:org.fastnate    文件:AbstractCsvReader.java   
/**
 * Creates a new instance of {@link AbstractCsvReader}.
 *
 * @param importPath
 *            the path to a file or to a directory that contains *.csv files
 */
public AbstractCsvReader(final File importPath) {
    this.importFiles = new ArrayList<>();
    if (!importPath.exists()) {
        throw new IllegalArgumentException("Path not found: " + importPath.getAbsolutePath());
    }
    if (importPath.isDirectory()) {
        this.importFiles.addAll(Arrays.asList(importPath.listFiles((FilenameFilter) new SuffixFileFilter(".csv"))));
    } else {
        this.importFiles.add(importPath);
    }
}
项目:gocd    文件:JobResourceImporter.java   
File[] getArtifactFilesOfType(String artifactsPathFromRoot, String jobArtifactPath, final String fileExtension) {
    LOGGER.debug("getArtifactFilesOfType({}, {}, {})", artifactsPathFromRoot, jobArtifactPath, fileExtension);

    File jobArtifactFile = new File(artifactBaseDir, artifactsPathFromRoot + File.separator + jobArtifactPath);
    LOGGER.debug("Artifact directory calculated to be {}", jobArtifactFile.getAbsolutePath());

    if (!jobArtifactFile.exists() || !jobArtifactFile.isDirectory()) {
        return new File[0];
    }

    Collection collection = FileUtils.listFiles(jobArtifactFile, new SuffixFileFilter(fileExtension, IOCase.INSENSITIVE), TrueFileFilter.INSTANCE);
    LOGGER.debug("{} artifact files found.", collection.size());
    return (File[]) collection.toArray(new File[0]);
}