Java Code Examples for java.io.FileFilter

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project android_packages_apps_VoiceDialer_2, under directory /src/com/android/voicedialer/.

Source file: RecognizerLogger.java

  18 
vote

/** 
 * Delete oldest files with a given suffix, if more than MAX_FILES.
 * @param suffix delete oldest files with this suffix.
 */
private void deleteOldest(final String suffix){
  FileFilter ff=new FileFilter(){
    public boolean accept(    File f){
      String name=f.getName();
      return name.startsWith("log_") && name.endsWith(suffix);
    }
  }
;
  File[] files=(new File(mDatedPath)).getParentFile().listFiles(ff);
  Arrays.sort(files);
  for (int i=0; i < files.length - MAX_FILES; i++) {
    files[i].delete();
  }
}
 

Example 2

From project bitcask-java, under directory /src/main/java/com/trifork/bitcask/.

Source file: BitCask.java

  18 
vote

private File[] list_data_files(final File writing_file,final File merging_file){
  File[] files=dirname.listFiles(new FileFilter(){
    @Override public boolean accept(    File f){
      if (f == writing_file || f == merging_file)       return false;
      return DATA_FILE.matcher(f.getName()).matches();
    }
  }
);
  Arrays.sort(files,0,files.length,REVERSE_DATA_FILE_COMPARATOR);
  return files;
}
 

Example 3

From project heritrix3, under directory /commons/src/main/java/org/archive/util/.

Source file: FileUtils.java

  18 
vote

/** 
 * Get a list of all files in directory that have passed prefix.
 * @param dir Dir to look in.
 * @param prefix Basename of files to look for. Compare is case insensitive.
 * @return List of files in dir that start w/ passed basename.
 */
public static File[] getFilesWithPrefix(File dir,final String prefix){
  FileFilter prefixFilter=new FileFilter(){
    public boolean accept(    File pathname){
      return pathname.getName().toLowerCase().startsWith(prefix.toLowerCase());
    }
  }
;
  return dir.listFiles(prefixFilter);
}
 

Example 4

From project jninka, under directory /jninka-parent/jninka-core/src/main/java/org/whitesource/jninka/.

Source file: JNinka.java

  18 
vote

private FileFilter getDirectoryFilter(){
  FileFilter result=new FileFilter(){
    @Override public boolean accept(    File pathname){
      return pathname.isDirectory();
    }
  }
;
  return result;
}
 

Example 5

From project lenya, under directory /org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/file/.

Source file: FileItemManager.java

  18 
vote

/** 
 * Get a file filter which filters for files containing items.
 * @return a <code>FileFilter</code>
 */
protected FileFilter getFileFilter(){
  FileFilter filter=new FileFilter(){
    public boolean accept(    File pathname){
      return (pathname.getName().endsWith(getSuffix()));
    }
  }
;
  return filter;
}
 

Example 6

From project liferay-maven-support, under directory /plugins/liferay-maven-plugin/src/main/java/com/liferay/maven/plugins/.

Source file: SassToCssBuilderMojo.java

  18 
vote

protected void doExecute() throws Exception {
  FileFilter fileFilter=FileFilterUtils.orFileFilter(DirectoryFileFilter.DIRECTORY,FileFilterUtils.andFileFilter(FileFileFilter.FILE,FileFilterUtils.suffixFileFilter(".css")));
  FileUtils.copyDirectory(webappSourceDir,webappDir,fileFilter,true);
  List<String> dirNames=new ArrayList<String>();
  for (  String dirName : StringUtil.split(sassDirNames)) {
    dirNames.add(dirName);
  }
  new SassToCssBuilder(dirNames);
}
 

Example 7

From project ant4eclipse, under directory /org.ant4eclipse.lib.jdt.ecj/src/org/ant4eclipse/lib/jdt/ecj/internal/tools/loader/.

Source file: ClasspathClassFileLoaderImpl.java

  17 
vote

/** 
 * @param directory
 * @return
 */
private String[] getAllPackagesFromDirectory(File directory){
  List<String> result=new LinkedList<String>();
  File[] children=directory.listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      return pathname.isDirectory();
    }
  }
);
  for (  File element : children) {
    getAllPackagesFromDirectory(null,element,result);
  }
  return result.toArray(new String[0]);
}
 

Example 8

From project apb, under directory /modules/apb-base/src/apb/testrunner/output/.

Source file: JUnitTestReport.java

  17 
vote

private File[] listReportFiles(final File targetFile){
  return reportsDir.listFiles(new FileFilter(){
    @Override public boolean accept(    File file){
      return !file.equals(targetFile) && file.getName().endsWith(".xml");
    }
  }
);
}
 

Example 9

From project ardverk-dht, under directory /components/core/src/main/java/org/ardverk/dht/storage/.

Source file: PersistentDatastore.java

  17 
vote

@Override protected void evict(long timeout,TimeUnit unit){
  final long now=System.currentTimeMillis();
  final long timeoutInMillis=unit.toMillis(timeout);
  FileFilter filter=new FileFilter(){
    @Override public boolean accept(    File file){
      if (file.isFile()) {
        if ((now - file.lastModified()) >= timeoutInMillis) {
          if (LOG.isTraceEnabled()) {
            LOG.trace("Deleting: " + file);
          }
          file.delete();
        }
      }
      return false;
    }
  }
;
  store.listFiles(filter);
  tmp.listFiles(filter);
}
 

Example 10

From project b3log-latke, under directory /latke-client/src/main/java/org/b3log/latke/client/.

Source file: LatkeClient.java

  17 
vote

/** 
 * Gets repository names from backup directory. <p> The returned repository names is the sub-directory names of the backup directory. </p>
 * @return repository backup directory name
 */
private static Set<String> getRepositoryNamesFromBackupDir(){
  final File[] repositoryBackupDirs=backupDir.listFiles(new FileFilter(){
    @Override public boolean accept(    final File file){
      return file.isDirectory();
    }
  }
);
  final Set<String> ret=new HashSet<String>();
  for (int i=0; i < repositoryBackupDirs.length; i++) {
    final File file=repositoryBackupDirs[i];
    ret.add(file.getName());
  }
  return ret;
}
 

Example 11

From project backup-plugin, under directory /src/main/java/org/jvnet/hudson/plugins/backup/utils/.

Source file: BackupTask.java

  17 
vote

/** 
 * Returns a file filter filtering files/dirs to NOT include from jobs' workspace (this means the returned file filter is already a negation).
 */
public static IOFileFilter createJobsExclusionFileFilter(String hudsonWorkDir,String jobIncludes,String jobExcludes,boolean caseSensitive){
  DirectoryScanner directoryScanner=new DirectoryScanner();
  directoryScanner.setBasedir(new File(hudsonWorkDir,JOBS_NAME));
  directoryScanner.setCaseSensitive(caseSensitive);
  if (jobIncludes != null && jobIncludes.length() > 0) {
    jobIncludes=jobIncludes.replaceAll(Matcher.quoteReplacement("\\"),"/");
    jobIncludes="*/" + WORKSPACE_NAME + '/'+ jobIncludes;
    jobIncludes=jobIncludes.replaceAll(",",",*/" + WORKSPACE_NAME + '/');
    directoryScanner.setIncludes(jobIncludes.split(","));
  }
 else {
    directoryScanner.setIncludes(null);
  }
  if (jobExcludes != null && jobExcludes.length() > 0) {
    jobExcludes=jobExcludes.replaceAll(Matcher.quoteReplacement("\\"),"/");
    jobExcludes="*/" + WORKSPACE_NAME + '/'+ jobExcludes;
    jobExcludes=jobExcludes.replaceAll(",",",*/" + WORKSPACE_NAME + '/');
    directoryScanner.setExcludes(jobExcludes.split(","));
  }
 else {
    directoryScanner.setExcludes(null);
  }
  directoryScanner.scan();
  FileFilter ff=new SimpleFileFilter(directoryScanner.getBasedir(),directoryScanner.getExcludedDirectories(),directoryScanner.getExcludedFiles());
  return FileFilterUtils.notFileFilter(new DelegateFileFilter(ff));
}
 

Example 12

From project bndtools, under directory /bndtools.core/src/bndtools/builder/.

Source file: NewBuilder.java

  17 
vote

private Set<File> findJarsInTarget() throws Exception {
  File targetDir=model.getTarget();
  File[] targetJars=targetDir.listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      return pathname.getName().toLowerCase().endsWith(".jar");
    }
  }
);
  Set<File> result=new HashSet<File>();
  if (targetJars != null)   for (  File jar : targetJars) {
    result.add(jar);
  }
  return result;
}
 

Example 13

From project Clotho-Core, under directory /ClothoApps/PluginManager/src/org/clothocore/tool/pluginmanager/io/.

Source file: FileTreeWalker.java

  17 
vote

public FileTreeWalker(File path) throws IOException {
  this(path,new FileFilter(){
    public boolean accept(    File pathname){
      return pathname.isFile();
    }
  }
);
}
 

Example 14

From project cloudify, under directory /USM/src/main/java/org/cloudifysource/usm/launcher/.

Source file: DefaultProcessLauncher.java

  17 
vote

private File[] getJarFilesFromDir(final File dir){
  final File[] jars=dir.listFiles(new FileFilter(){
    @Override public boolean accept(    final File pathname){
      return pathname.getName().endsWith(".jar") && pathname.isFile();
    }
  }
);
  return jars;
}
 

Example 15

From project cp-common-utils, under directory /src/com/clarkparsia/common/io/.

Source file: Files2.java

  17 
vote

/** 
 * Recursively traverse the directory and all its sub directories and return a list of all the files contained within.
 * @param theDirectory the start directory
 * @return all files in the start directory and all its sub directories.
 */
public static List<File> listFiles(File theDirectory){
  return listFiles(theDirectory,new FileFilter(){
    public boolean accept(    File theFile){
      return true;
    }
  }
);
}
 

Example 16

From project cpp-maven-plugins, under directory /cpp-plugin-tools/src/main/java/com/ericsson/tools/cpp/tools/settings/.

Source file: PluginSettingsImpl.java

  17 
vote

public Collection<File> getDependencyDirectories(final String scope,Environment targetEnvironment,boolean noArch){
  final FileFilter dirFilter=new FileFilter(){
    @Override public boolean accept(    File file){
      return file.isDirectory();
    }
  }
;
  final File dependDir=getExtractedDependenciesDirectory(scope);
  final Collection<File> dependencies=new ArrayList<File>();
  if (dependDir.isDirectory()) {
    final File[] groups=dependDir.listFiles(dirFilter);
    for (    File group : groups) {
      final File[] artifacts=group.listFiles(dirFilter);
      for (      File artifact : artifacts) {
        final File[] classifiers=artifact.listFiles(dirFilter);
        for (        File classifier : classifiers) {
          if (targetEnvironment != null) {
            for (            String candidate : targetEnvironment.getCandidateNames()) {
              File archDir=new File(classifier,candidate);
              if (archDir.exists() && archDir.isDirectory()) {
                dependencies.add(archDir);
              }
            }
          }
          if (noArch) {
            File noArchDir=new File(classifier,EnvironmentManager.NOARCH_NAME);
            if (noArchDir.exists())             dependencies.add(noArchDir);
          }
        }
      }
    }
  }
  return dependencies;
}
 

Example 17

From project cpptasks-parallel, under directory /src/main/java/net/sf/antcontrib/cpptasks/.

Source file: CCTask.java

  17 
vote

public void run(){
  if (rebuildCount < 10)   return;
  try {
    FileFilter updatedFiles=new FileFilter(){
      private long startTime=System.currentTimeMillis();
      public boolean accept(      File file){
        return file.lastModified() > startTime && !file.getName().endsWith(".xml");
      }
    }
;
    while (!stop) {
      System.err.print("\r" + objDir.listFiles(updatedFiles).length + " / "+ rebuildCount+ " files compiled...");
      System.err.print("\r");
      System.err.flush();
      if (!stop) {
        Thread.sleep(5000);
      }
    }
  }
 catch (  InterruptedException e) {
  }
  System.err.print("\r                                                                    ");
  System.err.print("\r");
  System.err.flush();
  log(Integer.toString(rebuildCount) + " files were compiled.");
}
 

Example 18

From project daily-money, under directory /dailymoney/src/com/bottleworks/commons/util/.

Source file: Files.java

  17 
vote

public static void deepClean(File folder){
  File[] folders=folder.listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      return pathname.isDirectory();
    }
  }
);
  for (  File f : folders) {
    deepClean(f);
    f.delete();
  }
  clean(folder);
}
 

Example 19

From project datasalt-utils, under directory /src/contrib/java/org/apache/solr/core/.

Source file: SolrResourceLoader.java

  17 
vote

/** 
 * Adds the specific file/dir specified to the ClassLoader used by this ResourceLoader.  This method <b>MUST</b> only be called prior to using this ResourceLoader to get any resources, otherwise it's behavior will be non-deterministic.
 * @param path A jar file (or directory of classes) to be added to the classpath,will be resolved relative the instance dir.
 */
void addToClassLoader(final String path){
  final File file=FileUtils.resolvePath(new File(getInstanceDir()),path);
  if (file.canRead()) {
    this.classLoader=replaceClassLoader(classLoader,file.getParentFile(),new FileFilter(){
      public boolean accept(      File pathname){
        return pathname.equals(file);
      }
    }
);
  }
 else {
    log.error("Can't find (or read) file to add to classloader: " + file);
  }
}
 

Example 20

From project dawn-workflow, under directory /org.dawb.passerelle.actors/src/org/dawb/passerelle/actors/data/.

Source file: FolderMonitorSource.java

  17 
vote

private File[] getNewerFileList(File file){
  return file.listFiles(new FileFilter(){
    @Override public boolean accept(    File child){
      if (reportedFiles.contains(new FileObject(child)))       return false;
      final long lm=child.lastModified();
      return lm > initTime;
    }
  }
);
}
 

Example 21

From project Diver, under directory /ca.uvic.chisel.logging.eclipse/src/ca/uvic/chisel/logging/eclipse/internal/.

Source file: Log.java

  17 
vote

/** 
 * Returns all the files that are used as backup.
 * @return
 */
public File[] getBackupFiles(){
  File[] children=category.getLogLocation().listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      String fileName=pathname.getName();
      return fileName.endsWith(".zip");
    }
  }
);
  return children;
}
 

Example 22

From project eclim, under directory /org.eclim/java/org/eclim/eclipse/.

Source file: EclimDaemon.java

  17 
vote

/** 
 * Builds the classloader used for third party nailgun extensions dropped into eclim's ext dir.
 * @return The classloader.
 */
private ClassLoader getExtensionClassLoader() throws Exception {
  File extdir=new File(FileUtils.concat(Services.DOT_ECLIM,"resources/ext"));
  if (extdir.exists()) {
    FileFilter filter=new FileFilter(){
      public boolean accept(      File file){
        return file.isDirectory() || file.getName().endsWith(".jar");
      }
    }
;
    ArrayList<URL> urls=new ArrayList<URL>();
    listFileUrls(extdir,filter,urls);
    return new URLClassLoader(urls.toArray(new URL[urls.size()]),this.getClass().getClassLoader());
  }
  return null;
}
 

Example 23

From project Eclipse, under directory /com.mobilesorcery.sdk.html5/src/com/mobilesorcery/sdk/html5/.

Source file: HTML5DebugSupportBuildStep.java

  17 
vote

private void copyUninstrumentedFiles(IProgressMonitor monitor,File inputRoot,File outputRoot) throws IOException {
  Util.copyDir(new SubProgressMonitor(monitor,3),inputRoot,outputRoot,new FileFilter(){
    @Override public boolean accept(    File file){
      return !JSODDSupport.isValidJavaScriptFile(new Path(file.getAbsolutePath()));
    }
  }
);
}
 

Example 24

From project enterprise, under directory /ha/src/main/java/org/neo4j/kernel/.

Source file: HighlyAvailableGraphDatabase.java

  17 
vote

/** 
 * Moves all files from the temp directory to the current working directory. Assumes the target files do not exist and skips over the messages.log file the temp db creates.
 * @throws IOException if move wasn't successful.
 */
private void moveCopiedStoreIntoWorkingDir() throws IOException {
  File storeDir=new File(getStoreDir());
  for (  File candidate : getTempDir().listFiles(new FileFilter(){
    @Override public boolean accept(    File file){
      return !file.getName().equals(StringLogger.DEFAULT_NAME);
    }
  }
)) {
    FileUtils.moveFileToDirectory(candidate,storeDir);
  }
}
 

Example 25

From project eventtracker, under directory /smile/src/test/java/com/ning/metrics/eventtracker/.

Source file: TestInvalidPayload.java

  17 
vote

private File[] listBinFiles(final File dir){
  return dir.listFiles(new FileFilter(){
    @Override public boolean accept(    final File pathname){
      return pathname.getName().endsWith(".bin");
    }
  }
);
}
 

Example 26

From project Extlet6, under directory /liferay-6.0.5-patch/portal-impl/src/com/liferay/portal/deploy/hot/.

Source file: ExtHotDeployListener.java

  17 
vote

protected void installWebInfJar(String portalWebDir,String pluginWebDir,String servletContextName) throws Exception {
  String zipName=portalWebDir + "WEB-INF/lib/ext-" + servletContextName+ "-webinf"+ ".jar";
  File dir=new File(pluginWebDir + "WEB-INF/ext-web/docroot/WEB-INF");
  if (!dir.isDirectory()) {
    throw new IllegalArgumentException("Not a directory: " + dir);
  }
  File[] files=dir.listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      return ExtRegistry.isMergedFile(pathname.getPath());
    }
  }
);
  zipWebInfJar(zipName,files);
}
 

Example 27

From project Gmote, under directory /gmoteserver/src/org/gmote/server/.

Source file: GmoteServer.java

  17 
vote

/** 
 * Creates a packet with the list of the files in the current directory.
 */
ListReplyPacket createListFilesPacket(String directory){
  File file=new File(directory);
  FileFilter filter=new FileFilter(){
    public boolean accept(    File arg0){
      if (arg0.isHidden()) {
        return false;
      }
      if (arg0.isDirectory()) {
        return true;
      }
      String name=arg0.getName().toLowerCase();
      if (SupportedFiletypeSettings.fileNameToFileType(name) != FileType.UNKNOWN) {
        return true;
      }
      boolean showAllFiles=DefaultSettings.instance().getSetting(DefaultSettingsEnum.SHOW_ALL_FILES).equalsIgnoreCase("true");
      if (showAllFiles) {
        return true;
      }
      return false;
    }
  }
;
  File[] listOfFiles=file.listFiles(filter);
  FileInfo[] fileInfo=convertFileListToFileInfo(listOfFiles);
  Arrays.sort(fileInfo);
  ListReplyPacket packet=new ListReplyPacket(fileInfo);
  return packet;
}
 

Example 28

From project gxa, under directory /atlas-loader/src/main/java/uk/ac/ebi/gxa/loader/steps/.

Source file: HTSAnnotationStep.java

  17 
vote

/** 
 * Populates into experiment's ncdf directory a .gtf annotation file (needed by WiggleRequestHandler) corresponding to the first species associated with experiment for which such .gtf file exists in experiment's HTS processing directory (N.B. assumptions below) <p/> Assumptions: 1. Processed HTS experiment's sdrf file resides in <processing_dir>/<experiment_accession>/data/<experiment_accession>.sdrf.txt 2. <processing_dir> contains a soft link, ANNOTATIONS, pointing to a directory containing .gtf files corresponding to all species needed to load HTS-experiments into Atlas. The files inside <processing_dir>/<experiment_accession>/ANNOTATIONS are e.g. Caenorhabditis_elegans.WS220.65.gtf where 65 is the release number of the Ensembl release against which experiment was processed. To avoid confusion only one Ensembl release's gtf file is allowed to be stored in <processing_dir>/ANNOTATIONS per species (an error will be thrown otherwise)
 * @param experiment
 * @param investigation
 * @param atlasDataDAO
 * @throws AtlasLoaderException if1. <ncdf_dir>/<experiment_acc>/ANNOTATIONS dir does not exist and could not be created; 2. <processing_dir>/<experiment_accession>/ANNOTATIONS directory does not exist 3. More than one <processing_dir>/<experiment_accession>/ANNOTATIONS/.gtf file exists for a given experiment's species (it could be that more than one Ensembl release's gtf files are stored under <processing_dir>/<experiment_accession>/ANNOTATIONS; this leads to error as we need to be sure which Ensembl release we are loading annotations for) 4. There was an error copying a gtf file from <processing_dir>/<experiment_accession>/ANNOTATIONS/ to  <ncdf_dir>/<experiment_acc>/ANNOTATIONS 5. No .gtf files were found for any of the experiment's species
 */
public void populateAnnotationsForSpecies(MAGETABInvestigation investigation,Experiment experiment,AtlasDataDAO atlasDataDAO) throws AtlasLoaderException {
  Collection<String> species=experiment.getSpecies();
  File sdrfFilePath=new File(investigation.SDRF.getLocation().getFile());
  File htsAnnotationsDir=new File(sdrfFilePath.getParentFile().getParentFile(),ANNOTATIONS);
  if (!htsAnnotationsDir.exists())   throw new AtlasLoaderException("Cannot find " + htsAnnotationsDir.getAbsolutePath() + "folder to retrieve annotations from for experiment: "+ experiment.getAccession());
  boolean found=false;
  for (  String specie : species) {
    if (found)     continue;
    String encodedSpecies=StringUtil.upcaseFirst(specie.replaceAll(" ","_"));
    FileFilter fileFilter=new WildcardFileFilter(encodedSpecies + "*" + ".gtf");
    File[] files=htsAnnotationsDir.listFiles(fileFilter);
    File experimentAnnotationsDir=null;
    try {
      experimentAnnotationsDir=new File(atlasDataDAO.getDataDirectory(experiment),ANNOTATIONS);
      if (!experimentAnnotationsDir.exists() && !experimentAnnotationsDir.mkdirs()) {
        throw new AtlasLoaderException("Cannot create folder to insert annotations into for experiment: " + experiment.getAccession());
      }
      if (files.length == 1) {
        GeneAnnotationFormatConverterService.transferAnnotation(files[0],new File(experimentAnnotationsDir,files[0].getName().replaceAll(GTF_EXT_PATTERN,ANNO_EXT_PATTERN)));
        found=true;
      }
 else       if (files.length > 0) {
        throw new AtlasLoaderException("More than one file in Gene Annotation Format (.gtf) exists in " + htsAnnotationsDir.getAbsolutePath() + " for experiment: "+ experiment.getAccession()+ " and species: "+ specie);
      }
    }
 catch (    IOException ioe) {
      throw new AtlasLoaderException("Error copying annotations from: " + files[0].getAbsolutePath() + " to: "+ experimentAnnotationsDir.getAbsolutePath()+ " for experiment: "+ experiment.getAccession(),ioe);
    }
  }
  if (!found)   throw new AtlasLoaderException("Failed to find any files in Gene Annotation Format (.gtf) in " + htsAnnotationsDir.getAbsolutePath() + " for experiment: "+ experiment.getAccession());
}
 

Example 29

From project hsDroid, under directory /src/de/nware/app/hsDroid/ui/.

Source file: DirChooser.java

  17 
vote

private void prepareDirectoryList(){
  final ArrayList<File> sdDirs=new ArrayList<File>();
  if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
    File extDir=Environment.getExternalStorageDirectory();
    FileFilter dirFilter=new FileFilter(){
      @Override public boolean accept(      File pathname){
        return pathname.isDirectory();
      }
    }
;
    for (    File file : extDir.listFiles(dirFilter)) {
      if (!file.isHidden()) {
        sdDirs.add(file);
      }
    }
    Collections.sort(sdDirs);
    getListView().setAdapter(new ArrayAdapter<File>(getApplicationContext(),R.layout.dir_chooser_item,sdDirs));
    getListView().setOnItemClickListener(new OnItemClickListener(){
      @Override public void onItemClick(      AdapterView<?> parent,      View view,      int pos,      long id){
        showToast(sdDirs.get(pos).getAbsolutePath());
        Editor ed=sPreferences.edit();
        ed.putString("downloadPathPref",sdDirs.get(pos).getAbsolutePath());
        ed.commit();
        finish();
      }
    }
);
  }
 else {
    showToast(getString(R.string.error_nosdcard));
  }
}
 

Example 30

From project ihtika, under directory /Incubator/ForInstaller/PackLibs/src/com/google/code/ihtika/IhtikaClient/packlibs/.

Source file: Pack.java

  17 
vote

private void recursivePack(File currentDir){
  Pack200.Packer packer=Pack200.newPacker();
  Map p=packer.properties();
  p.put(packer.EFFORT,"9");
  FileFilter filefilter=new FileFilter(){
    @Override public boolean accept(    File file){
      if ((file.getName().endsWith(".jar") || file.getName().endsWith(".jar.svn-base")) && !file.getName().equals("PackLibs.jar")) {
        return true;
      }
      return false;
    }
  }
;
  for (  File lib : currentDir.listFiles(filefilter)) {
    try {
      throw new Exception();
    }
 catch (    Exception ex) {
    }
    try {
      System.out.println("Processing file " + lib.getAbsolutePath());
      JarFile jarFile=new JarFile(lib);
      FileOutputStream fos=new FileOutputStream(lib.getAbsolutePath() + PACKEXT);
      packer.pack(jarFile,fos);
      jarFile.close();
      fos.close();
      gZip.gzipFile(lib.getAbsolutePath() + PACKEXT,lib.getAbsolutePath() + PACKEXT + ".gz");
      new File(lib.getAbsolutePath() + PACKEXT).delete();
      lib.delete();
    }
 catch (    Exception ex) {
    }
  }
  for (  File dir : currentDir.listFiles()) {
    if (dir.isDirectory()) {
      recursivePack(dir);
    }
  }
}
 

Example 31

From project jclouds-bean-cleaner, under directory /src/main/java/org/jclouds/cleanup/.

Source file: DomainObjectDocletCleaner.java

  17 
vote

private static List<File> listFiles(File file,List<File> result){
  if (file.isDirectory()) {
    for (    File directory : file.listFiles(new FileFilter(){
      public boolean accept(      File file){
        return file.isDirectory();
      }
    }
)) {
      listFiles(directory,result);
    }
    result.addAll(Arrays.asList(file.listFiles(new PatternFilenameFilter(".*\\.java"))));
  }
  return result;
}
 

Example 32

From project jetty-project, under directory /jetty-jspc-maven-plugin/src/main/java/org/mortbay/jetty/jspc/plugin/.

Source file: JspcMojo.java

  17 
vote

/** 
 * Until Jasper supports the option to generate the srcs in a different dir than the classes, this is the best we can do.
 * @throws Exception
 */
public void cleanupSrcs() throws Exception {
  if (!keepSources) {
    File generatedClassesDir=new File(generatedClasses);
    if (generatedClassesDir.exists() && generatedClassesDir.isDirectory()) {
      delete(generatedClassesDir,new FileFilter(){
        public boolean accept(        File f){
          return f.isDirectory() || f.getName().endsWith(".java");
        }
      }
);
    }
  }
}
 

Example 33

From project maven-android-plugin, under directory /src/main/java/com/jayway/maven/plugins/android/phase09package/.

Source file: ApkMojo.java

  17 
vote

private void copyLocalNativeLibraries(final File localNativeLibrariesDirectory,final File destinationDirectory) throws MojoExecutionException {
  getLog().debug("Copying existing native libraries from " + localNativeLibrariesDirectory);
  try {
    IOFileFilter libSuffixFilter=FileFilterUtils.suffixFileFilter(".so");
    IOFileFilter gdbserverNameFilter=FileFilterUtils.nameFileFilter("gdbserver");
    IOFileFilter orFilter=FileFilterUtils.or(libSuffixFilter,gdbserverNameFilter);
    IOFileFilter libFiles=FileFilterUtils.and(FileFileFilter.FILE,orFilter);
    FileFilter filter=FileFilterUtils.or(DirectoryFileFilter.DIRECTORY,libFiles);
    org.apache.commons.io.FileUtils.copyDirectory(localNativeLibrariesDirectory,destinationDirectory,filter);
  }
 catch (  IOException e) {
    getLog().error("Could not copy native libraries: " + e.getMessage(),e);
    throw new MojoExecutionException("Could not copy native dependency.",e);
  }
}
 

Example 34

From project maven-t7-plugin, under directory /src/main/java/com/googlecode/t7mp/steps/.

Source file: ResolveTomcatStep.java

  17 
vote

private void copyToTomcatDirectory(File unpackDirectory) throws IOException {
  File[] files=unpackDirectory.listFiles(new FileFilter(){
    @Override public boolean accept(    File file){
      return file.isDirectory();
    }
  }
);
  FileUtils.copyDirectory(files[0],this.configuration.getCatalinaBase());
}
 

Example 35

From project MEditor, under directory /editor-common/editor-common-server/src/main/java/cz/mzk/editor/server/handler/.

Source file: FindAltoOcrFilesHandler.java

  17 
vote

/** 
 * Scan directory structure.
 * @param path the path
 * @return the list
 */
private List<String> findAltoAndTxt(String path,final String typeToFind){
  List<String> fileNames=new ArrayList<String>();
  File pathFile=new File(path + File.separator + typeToFind+ File.separator);
  FileFilter filter=new FileFilter(){
    @Override public boolean accept(    File file){
      if (typeToFind.equals(ALTO)) {
        return file.isFile() && file.getName().toLowerCase().endsWith(".xml");
      }
 else {
        return file.isFile() && file.getName().toLowerCase().endsWith(".txt");
      }
    }
  }
;
  File[] files=pathFile.listFiles(filter);
  for (int i=0; (files != null && i < files.length); i++) {
    if (typeToFind.equals(ALTO)) {
      SAXReader reader=new SAXReader();
      try {
        reader.setValidation(true);
        reader.read(files[i]);
      }
 catch (      DocumentException e) {
      }
    }
    fileNames.add(path + File.separator + typeToFind+ File.separator+ files[i].getName());
  }
  return fileNames;
}
 

Example 36

From project mididuino, under directory /editor/app/src/processing/app/library/.

Source file: Library.java

  17 
vote

private File getUtilityFolder(){
  FileFilter filter=new FileFilter(){
    public boolean accept(    File file){
      if (file.isDirectory()) {
        if ((file.getName()).equalsIgnoreCase("utility")) {
          return true;
        }
      }
      return false;
    }
  }
;
  File[] files=libFolder.listFiles(filter);
  if (files.length > 0) {
    return files[0];
  }
  return null;
}
 

Example 37

From project arquillian_deprecated, under directory /extensions/performance/src/main/java/org/jboss/arquillian/performance/event/.

Source file: PerformanceResultStore.java

  16 
vote

/** 
 * @param suiteResult
 * @return
 */
private List<PerformanceSuiteResult> findEarlierResults(final PerformanceSuiteResult currentResult){
  File perfDir=new File(System.getProperty("user.dir") + File.separator + folder);
  File[] files=perfDir.listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      if (pathname.getName().startsWith(currentResult.getName()))       return true;
 else       return false;
    }
  }
);
  List<PerformanceSuiteResult> prevResults=new ArrayList<PerformanceSuiteResult>();
  if (files != null) {
    for (    File f : files) {
      PerformanceSuiteResult result=getResultFromFile(f);
      if (result != null)       prevResults.add(result);
    }
  }
  return prevResults;
}
 

Example 38

From project AudioBox.fm-JavaLib, under directory /audiobox.fm-sync/src/main/java/fm/audiobox/sync/task/.

Source file: Scan.java

  16 
vote

private void _startScan(File folder){
  File[] files=folder.listFiles(new FileFilter(){
    @Override public boolean accept(    File pathname){
      if (!pathname.canRead())       return false;
      if (pathname.isHidden() && !_hidden)       return false;
      if (pathname.isDirectory() && !_recursive)       return false;
      if (_ff != null) {
        return _ff.accept(pathname);
      }
 else {
        for (        String ext : ALLOWED_MEDIA)         if (pathname.getName().endsWith("." + ext))         return true;
      }
      return false;
    }
  }
);
  for (  File file : files) {
    if (this.isStopped())     return;
    if (file.isDirectory()) {
      this._startScan(file);
      continue;
    }
    this.files.add(file);
    this.getThreadListener().onProgress(this,0,0,0,file);
  }
}
 

Example 39

From project b3log-solo, under directory /core/src/main/java/org/b3log/solo/util/.

Source file: Skins.java

  16 
vote

/** 
 * Gets all skin directory names. Scans the {@linkplain SoloServletListener#getWebRoot() Web root}/skins/ directory, using the subdirectory of it as the skin directory name, for example, <pre> ${Web root}/skins/ <b>default</b>/ <b>mobile</b>/ <b>classic</b>/ </pre> Skips files that name starts with . and  {@linkplain File#isHidden() hidden} files.
 * @return a set of skin name, returns an empty set if not found
 */
public static Set<String> getSkinDirNames(){
  final String webRootPath=SoloServletListener.getWebRoot();
  final File skins=new File(webRootPath + "skins" + File.separator);
  final File[] skinDirs=skins.listFiles(new FileFilter(){
    @Override public boolean accept(    final File file){
      return file.isDirectory() && !file.getName().startsWith(".");
    }
  }
);
  final Set<String> ret=new HashSet<String>();
  if (null == skinDirs) {
    LOGGER.severe("Skin directory is null");
    return ret;
  }
  for (int i=0; i < skinDirs.length; i++) {
    final File file=skinDirs[i];
    ret.add(file.getName());
  }
  return ret;
}
 

Example 40

From project BeeQueue, under directory /lib/src/hyperic-sigar-1.6.4/bindings/java/examples/.

Source file: Runner.java

  16 
vote

public static URL[] getLibJars(String dir) throws Exception {
  File[] jars=new File(dir).listFiles(new FileFilter(){
    public boolean accept(    File file){
      String name=file.getName();
      int jarIx=name.indexOf(JAR_EXT);
      if (jarIx == -1) {
        return false;
      }
      int ix=name.indexOf('-');
      if (ix != -1) {
        name=name.substring(0,ix);
      }
 else {
        name=name.substring(0,jarIx);
      }
      if (wantedJars.get(name) != null) {
        wantedJars.put(name,Boolean.TRUE);
        return true;
      }
 else {
        return false;
      }
    }
  }
);
  if (jars == null) {
    return new URL[0];
  }
  URL[] urls=new URL[jars.length];
  for (int i=0; i < jars.length; i++) {
    URL url=new URL("jar",null,"file:" + jars[i].getAbsolutePath() + "!/");
    urls[i]=url;
  }
  return urls;
}
 

Example 41

From project book, under directory /src/main/java/com/tamingtext/util/.

Source file: FileUtil.java

  16 
vote

public static File[] buildFileList(File f){
  if (!f.isDirectory()) {
    throw new IllegalArgumentException(f + " is not a directory or does not exit");
  }
  File[] inputFiles=f.listFiles(new FileFilter(){
    @Override public boolean accept(    File pathname){
      if (pathname.isFile()) {
        String name=pathname.getName();
        if (name.startsWith(".") || name.endsWith(".crc")) {
          return false;
        }
        return true;
      }
      return false;
    }
  }
);
  return inputFiles;
}
 

Example 42

From project Briss, under directory /src/test/java/at/laborg/briss/.

Source file: AutoCropTest.java

  16 
vote

/** 
 * @param args
 */
public static void main(String[] args){
  File wd=new File(System.getProperty("user.dir") + File.separatorChar + "pdftests");
  File outputDirectory=new File(wd.getAbsolutePath() + File.separatorChar + new Date().toString());
  outputDirectory.mkdir();
  for (  File file : wd.listFiles(new FileFilter(){
    @Override public boolean accept(    File arg0){
      return arg0.getAbsolutePath().toLowerCase().endsWith(".pdf");
    }
  }
)) {
    String[] jobargs=new String[4];
    jobargs[0]="-s";
    jobargs[1]=file.getAbsolutePath();
    jobargs[2]="-d";
    File recommended=BrissFileHandling.getRecommendedDestination(file);
    String output=outputDirectory.getAbsolutePath() + File.separatorChar + recommended.getName();
    jobargs[3]=output;
    BrissCMD.autoCrop(jobargs);
  }
}
 

Example 43

From project bundlemaker, under directory /integrationtest/org.bundlemaker.itest.adhoc/src/org/bundlemaker/itest/adhoc/.

Source file: IntegrationTest.java

  16 
vote

@Override protected void doAddProjectDescription(IBundleMakerProject bundleMakerProject) throws Exception {
  bundleMakerProject.getModifiableProjectDescription().clear();
  bundleMakerProject.getModifiableProjectDescription().setJre(AbstractIntegrationTest.getDefaultVmName());
  File libsDir=new File(System.getProperty("user.dir"),"adhoc-input");
  File[] jarFiles=libsDir.listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      return !(pathname.getName().contains(".svn") || pathname.getName().contains(".SVN"));
    }
  }
);
  for (  File externalJar : jarFiles) {
    FileBasedContentProviderFactory.addNewFileBasedContentProvider(bundleMakerProject.getModifiableProjectDescription(),externalJar.getAbsolutePath());
  }
  bundleMakerProject.getModifiableProjectDescription().save();
}
 

Example 44

From project Carolina-Digital-Repository, under directory /persistence/src/main/java/edu/unc/lib/dl/services/.

Source file: BatchIngestQueue.java

  16 
vote

public File[] getFailedDirectories(){
  File[] batchDirs=this.failedDirectory.listFiles(new FileFilter(){
    @Override public boolean accept(    File arg0){
      return arg0.isDirectory();
    }
  }
);
  if (batchDirs != null) {
    Arrays.sort(batchDirs,new Comparator<File>(){
      @Override public int compare(      File o1,      File o2){
        if (o1 == null || o2 == null)         return 0;
        return (int)(o1.lastModified() - o2.lastModified());
      }
    }
);
    return batchDirs;
  }
 else {
    return new File[]{};
  }
}
 

Example 45

From project CIShell, under directory /templates/org.cishell.templates.tasks/src/org/cishell/templates/dataset/.

Source file: DatasetIntegrationTask.java

  16 
vote

protected void processDir(File dir) throws IOException {
  File[] files=dir.listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      if (pathname.isDirectory()) {
        return true;
      }
 else {
        return pathname.getName().endsWith(".properties");
      }
    }
  }
);
  for (int i=0; i < files.length; i++) {
    if (files[i].isDirectory()) {
      processDir(files[i]);
    }
 else {
      addDataset(files[i]);
    }
  }
}
 

Example 46

From project cmsandroid, under directory /src/com/zia/freshdocs/app/.

Source file: CMISApplication.java

  16 
vote

/** 
 * Handles cleaning up files from download events which are not saved as favorites.
 */
public void cleanupCache(){
  StringBuilder appStoragePath=getAppStoragePath();
  CMISPreferencesManager prefsMgr=CMISPreferencesManager.getInstance();
  final Set<NodeRef> favorites=prefsMgr.getFavorites(this);
  File storage=new File(appStoragePath.toString());
  if (favorites != null) {
    if (storage.exists() && storage.isDirectory()) {
      File[] files=storage.listFiles(new FileFilter(){
        public boolean accept(        File pathname){
          NodeRef ref=new NodeRef();
          ref.setName(pathname.getName());
          int index=Collections.binarySearch(new ArrayList<NodeRef>(favorites),ref,new Comparator<NodeRef>(){
            public int compare(            NodeRef object1,            NodeRef object2){
              return object1.getName().compareTo(object2.getName());
            }
          }
);
          return index < 0 && !pathname.isDirectory();
        }
      }
);
      int n=files.length;
      File file=null;
      for (int i=0; i < n; i++) {
        file=files[i];
        file.delete();
      }
    }
  }
}
 

Example 47

From project codjo-data-process, under directory /codjo-data-process-server/src/main/java/net/codjo/dataprocess/server/handlercommand/fmanager/.

Source file: DpFexplorerCommand.java

  16 
vote

@Override public CommandResult executeQuery(CommandQuery query) throws HandlerException, SQLException {
  StringBuilder response=new StringBuilder();
  String relativePath=query.getArgumentString("relativePath");
  File currentFile=new File("./" + relativePath);
  String realPath=currentFile.getAbsolutePath();
  response.append(realPath).append("\n").append("--DIRS").append("\n");
  File[] dirs=currentFile.listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      return pathname.isDirectory();
    }
  }
);
  if (dirs != null) {
    for (    File dir : dirs) {
      response.append(dir.getName()).append("\n");
    }
  }
  response.append("--FILES").append("\n");
  File[] files=currentFile.listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      return !pathname.isDirectory();
    }
  }
);
  if (files != null) {
    SimpleDateFormat simpleDateFormat=new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
    for (    File file : files) {
      Date date=new Date(file.lastModified());
      response.append(file.getName()).append("|").append(file.length()).append("|").append(simpleDateFormat.format(date)).append("\n");
    }
  }
  response.append("--EOC\n");
  return createResult(response.toString());
}
 

Example 48

From project codjo-webservices, under directory /codjo-webservices-generator/src/main/java/net/codjo/webservices/generator/.

Source file: ClassListGenerator.java

  16 
vote

public void generate(File sourcesDirectory,File targetDirectory,String packageName) throws IOException {
  File targetPackage=new File(sourcesDirectory,packageName.replace('.','/'));
  File resourcesDirectory=new File(targetDirectory,"resources");
  if (!resourcesDirectory.exists()) {
    resourcesDirectory.mkdirs();
  }
  File sourcesListFile=new File(resourcesDirectory,"sourcesList.txt");
  BufferedWriter out=new BufferedWriter(new FileWriter(sourcesListFile,true));
  File[] files=targetPackage.listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      return pathname.getName().endsWith(".java");
    }
  }
);
  for (  File file : files) {
    String className=file.getAbsolutePath();
    className=className.substring(targetDirectory.getAbsolutePath().length() + 1,className.length() - 5);
    out.write(className.replace(File.separator,"."));
    out.newLine();
  }
  out.close();
}
 

Example 49

From project dawn-common, under directory /org.dawb.common.ui/src/org/dawb/common/ui/views/.

Source file: ImageMonitorView.java

  16 
vote

/** 
 * This will be configured from options but  for now it is any image accepted.
 * @return
 */
protected FileFilter getFileFilter(){
  return new FileFilter(){
    @Override public boolean accept(    File pathname){
      if (pathname.isDirectory())       return false;
      if (pathname.isHidden())       return false;
      final String name=pathname.getName();
      if (name == null || "".equals(name))       return false;
      if (name.startsWith("."))       return false;
      if (name.endsWith(".edf"))       return true;
      if (ImageFileUtils.isImage(name))       return true;
      final String ext=FileUtils.getFileExtension(pathname);
      if (LoaderFactory.getSupportedExtensions().contains(ext))       return true;
      return false;
    }
  }
;
}
 

Example 50

From project dolphin, under directory /org.adarsh.jutils/javadoc/com/tan/javadoc/.

Source file: FieldsMain.java

  16 
vote

public static void main(String[] args){
  System.setProperty("sun.jnu.encoding","utf-8");
  System.setProperty("file.encoding","UTF-8");
  String path="D:\\PSWG\\workspace\\pswg\\src\\main\\java\\jp\\co\\pswg\\entity\\";
  File f=new File(path);
  if (!f.exists()) {
    TanUtil.warnln("???????");
  }
 else   if (f.isFile() && path.toLowerCase().endsWith(".java")) {
    JavDocMain.showFieldsInfo(new String[]{"javadoc",path,"-encoding","utf-8"});
  }
 else   if (f.isDirectory()) {
    File[] javas=f.listFiles(new FileFilter(){
      @Override public boolean accept(      File file){
        return file.isFile() && file.getName().toLowerCase().endsWith(".java");
      }
    }
);
    if (javas == null || javas.length == 0)     TanUtil.warnln("?????????java???");
    for (    File java : javas) {
      JavDocMain.showFieldsInfo(new String[]{"javadoc",java.getAbsolutePath(),"-encoding","utf-8"});
    }
  }
}
 

Example 51

From project EasySOA, under directory /easysoa-registry/easysoa-registry-api/easysoa-remote-frascati-test/src/main/java/org/easysoa/sca/frascati/test/.

Source file: RemoteFraSCAtiServiceProviderTest.java

  16 
vote

/** 
 * Search for the directory which name is passed on as a parameter. The first occurrence is returned
 * @param basedir the directory from where start the research
 * @param caller the directory from where comes the research
 * @param directoryName the searched directory's name
 * @return the directory if it has been found
 */
private File searchDirectory(File basedir,final File caller,final String directoryName){
  File[] children=basedir.listFiles(new FileFilter(){
    public boolean accept(    File f){
      if (f.isDirectory() && (caller == null || !(caller.getAbsolutePath().equals(f.getAbsoluteFile().getAbsolutePath())))) {
        return true;
      }
      return false;
    }
  }
);
  for (  File child : children) {
    if (directoryName.equals(child.getName())) {
      return child.getAbsoluteFile();
    }
    File c=searchDirectory(child.getAbsoluteFile(),basedir,directoryName);
    if (c != null) {
      return c.getAbsoluteFile();
    }
  }
  if (caller == null || !caller.getAbsolutePath().equals(basedir.getAbsoluteFile().getParentFile().getAbsolutePath())) {
    File c=searchDirectory(basedir.getParentFile(),basedir,directoryName);
    if (c != null) {
      return c.getAbsoluteFile();
    }
  }
  return null;
}
 

Example 52

From project edna-rcp, under directory /org.edna.datamodel.generateds/src/org/edna/datamodel/generateds/.

Source file: StandaloneSetup.java

  16 
vote

/** 
 * sets the platform uri for standalone execution
 * @param pathToPlatform
 */
public void setPlatformUri(String pathToPlatform){
  File f=new File(pathToPlatform);
  if (!f.exists())   throw new ConfigurationException("The platformUri location '" + pathToPlatform + "' does not exist");
  if (!f.isDirectory())   throw new ConfigurationException("The platformUri location must point to a directory");
  String path=f.getAbsolutePath();
  try {
    path=f.getCanonicalPath();
  }
 catch (  IOException e) {
    log.error("Error when registering platform location",e);
  }
  if (platformRootPath == null || !platformRootPath.equals(path)) {
    platformRootPath=path;
    log.info("Registering platform uri '" + path + "'");
    if (f.exists()) {
      final File[] files=f.listFiles(new FileFilter(){
        public boolean accept(        File arg0){
          return arg0.exists() && arg0.isDirectory() && !arg0.getName().startsWith(".");
        }
      }
);
      if (files != null) {
        for (        File subdir : files) {
          String s=subdir.getName();
          try {
            URI uri=URI.createFileURI(subdir.getCanonicalPath() + "/");
            EcorePlugin.getPlatformResourceMap().put(s,uri);
            if (log.isDebugEnabled()) {
              log.debug("Registering project " + s + " at '"+ subdir.getCanonicalPath()+ "'");
            }
          }
 catch (          IOException e) {
            throw new ConfigurationException("Error when registering platform location",e);
          }
        }
      }
    }
  }
}
 

Example 53

From project eik, under directory /plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/runtime/.

Source file: KarafRuntimeLocator.java

  16 
vote

/** 
 * Searches the given directory and all directories recursively to the given depth for Karaf server runtimes.
 * @param directory the current directory that is being searched
 * @param depth the max depth to search
 * @param listener the listener that will be notified if a Karaf server runtime is found
 * @param monitor the progress monitor
 */
private void searchDirectory(final File directory,final int depth,final IRuntimeSearchListener listener,final IProgressMonitor monitor){
  final IRuntimeWorkingCopy runtime=resolveDirectoryToRuntime(directory,monitor);
  if (runtime != null) {
    listener.runtimeFound(runtime);
  }
  if (depth == 0 || monitor.isCanceled()) {
    return;
  }
  final File[] files=directory.listFiles(new FileFilter(){
    @Override public boolean accept(    final File file){
      return file.isDirectory();
    }
  }
);
  if (files == null) {
    return;
  }
  for (  final File f : files) {
    if (monitor.isCanceled()) {
      return;
    }
    searchDirectory(f,depth - 1,listener,monitor);
  }
}
 

Example 54

From project flapjack, under directory /flapjack-annotation/src/main/java/flapjack/annotation/util/.

Source file: LocalFileSystemClassLocator.java

  16 
vote

protected void findClasses(List<Class> classes,URL url,Pattern packageNamePattern){
  try {
    File dir=new File(url.toURI());
    File files[]=dir.listFiles(new FileFilter(){
      public boolean accept(      File file){
        return file.getName().endsWith(".class");
      }
    }
);
    for (    File file : files) {
      String className=convertFilePathToPackage(file);
      if (packageNamePattern.matcher(className).find()) {
        classes.add(goUntilItLoads(trimOfClassExtension(className)));
      }
    }
  }
 catch (  URISyntaxException e) {
    throw new RuntimeException(e);
  }
}
 

Example 55

From project gda-common, under directory /uk.ac.gda.common/src/uk/ac/gda/util/io/.

Source file: SortingUtils.java

  16 
vote

private static List<File> getSortedFileList(final File dir,final Comparator<File> comp,final boolean dirsFirst){
  if (!dir.isDirectory())   return null;
  if (dir.listFiles() == null)   return null;
  final List<File> ret;
  if (dirsFirst) {
    ret=new ArrayList<File>(dir.listFiles().length);
    final List<File> dirs=getSortedFileList(dir.listFiles(new FileFilter(){
      @Override public boolean accept(      File pathname){
        return pathname.isDirectory();
      }
    }
),comp);
    if (dirs != null)     ret.addAll(dirs);
    final List<File> files=getSortedFileList(dir.listFiles(new FileFilter(){
      @Override public boolean accept(      File pathname){
        return !pathname.isDirectory();
      }
    }
),comp);
    if (files != null)     ret.addAll(files);
  }
 else {
    ret=getSortedFileList(dir.listFiles(),comp);
  }
  if (ret.isEmpty())   return null;
  return ret;
}
 

Example 56

From project Gemini-Blueprint, under directory /test-support/src/main/java/org/eclipse/gemini/blueprint/test/provisioning/internal/.

Source file: MavenPackagedArtifactFinder.java

  16 
vote

private File findInDirectoryTree(String fileName,File root){
  boolean trace=log.isTraceEnabled();
  File targetDir=new File(root,TARGET);
  if (targetDir.exists()) {
    File artifact=new File(targetDir,fileName);
    if (artifact.exists()) {
      if (trace)       log.trace("Found artifact at " + artifact.getAbsolutePath() + "; checking the pom.xml groupId...");
      File pomXml=new File(root,POM_XML);
      String groupId=getGroupIdFromPom(new FileSystemResource(pomXml));
      if (trace)       log.trace("Pom [" + pomXml.getAbsolutePath() + "] has groupId ["+ groupId+ "]");
      if (this.groupId.equals(groupId))       return artifact;
    }
  }
  File[] children=root.listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      if (!isMavenProjectDirectory(pathname)) {
        return false;
      }
      if (pathname.getName().equals(TARGET)) {
        return false;
      }
      if (pathname.getName().equals("src")) {
        return false;
      }
      if (pathname.getName().equals(".svn")) {
        return false;
      }
      return true;
    }
  }
);
  for (int i=0; i < children.length; i++) {
    File found=findInDirectoryTree(fileName,children[i]);
    if (found != null) {
      return found;
    }
  }
  return null;
}
 

Example 57

From project gitblit, under directory /src/com/gitblit/.

Source file: GitBlit.java

  16 
vote

/** 
 * Returns the list of pending federation proposals
 * @return list of federation proposals
 */
public List<FederationProposal> getPendingFederationProposals(){
  List<FederationProposal> list=new ArrayList<FederationProposal>();
  File folder=getProposalsFolder();
  if (folder.exists()) {
    File[] files=folder.listFiles(new FileFilter(){
      @Override public boolean accept(      File file){
        return file.isFile() && file.getName().toLowerCase().endsWith(Constants.PROPOSAL_EXT);
      }
    }
);
    for (    File file : files) {
      String json=com.gitblit.utils.FileUtils.readContent(file,null);
      FederationProposal proposal=JsonUtils.fromJsonString(json,FederationProposal.class);
      list.add(proposal);
    }
  }
  return list;
}
 

Example 58

From project grails-ide, under directory /org.grails.ide.eclipse.test/src/org/grails/ide/eclipse/test/.

Source file: GrailsTestsActivator.java

  16 
vote

protected static List<String> findFiles(File file,final boolean recursive){
  final List<String> files=new ArrayList<String>();
  file.listFiles(new FileFilter(){
    public boolean accept(    File file){
      if (file.getName().endsWith(".jar") && !file.getPath().contains("xalan") && !file.getPath().contains("itext")) {
        files.add(file.getAbsolutePath());
      }
      if (recursive && file.isDirectory()) {
        file.listFiles(this);
      }
      return false;
    }
  }
);
  return files;
}
 

Example 59

From project griffon, under directory /subprojects/griffon-wrapper/src/main/java/org/gradle/wrapper/.

Source file: BootstrapMainStarter.java

  16 
vote

public void start(String[] args,File griffonHome) throws Exception {
  boolean debug=GriffonWrapperMain.isDebug();
  List<File> libs=new ArrayList<File>();
  libs.addAll(findLauncherJars(griffonHome));
  File[] files=new File(griffonHome,"lib").listFiles(new FileFilter(){
    public boolean accept(    File file){
      return file.getAbsolutePath().endsWith(".jar");
    }
  }
);
  for (  File file : files) {
    libs.add(file);
  }
  if (debug) {
    for (    File file : libs) {
      System.out.println(file.getAbsolutePath());
    }
  }
  int i=0;
  URL[] urls=new URL[libs.size()];
  for (  File file : libs) {
    urls[i++]=file.toURI().toURL();
  }
  String griffonHomeDirPath=griffonHome.getCanonicalPath();
  System.setProperty("griffon.home",griffonHome.getCanonicalPath());
  System.setProperty("program.name","Griffon");
  System.setProperty("base.dir",".");
  System.setProperty("groovy.starter.conf",griffonHomeDirPath + "/conf/groovy-starter.conf");
  URLClassLoader contextClassLoader=new URLClassLoader(urls);
  Class<?> mainClass=contextClassLoader.loadClass("org.codehaus.griffon.cli.support.GriffonStarter");
  Method mainMethod=mainClass.getMethod("main",String[].class);
  mainMethod.invoke(null,new Object[]{args});
}
 

Example 60

From project hawtbuf, under directory /hawtbuf-protoc/src/main/java/org/fusesource/hawtbuf/proto/compiler/.

Source file: ProtoMojo.java

  16 
vote

public void execute() throws MojoExecutionException {
  File[] mainFiles=null;
  if (mainSourceDirectory.exists()) {
    mainFiles=mainSourceDirectory.listFiles(new FileFilter(){
      public boolean accept(      File pathname){
        return pathname.getName().endsWith(".proto");
      }
    }
);
    if (mainFiles == null || mainFiles.length == 0) {
      getLog().warn("No proto files found in directory: " + mainSourceDirectory.getPath());
    }
 else {
      processFiles(mainFiles,mainOutputDirectory);
      this.project.addCompileSourceRoot(mainOutputDirectory.getAbsolutePath());
    }
  }
  File[] testFiles=null;
  if (testSourceDirectory.exists()) {
    testFiles=testSourceDirectory.listFiles(new FileFilter(){
      public boolean accept(      File pathname){
        return pathname.getName().endsWith(".proto");
      }
    }
);
    if (testFiles == null || testFiles.length == 0) {
      getLog().warn("No proto files found in directory: " + testSourceDirectory.getPath());
    }
 else {
      processFiles(testFiles,testOutputDirectory);
      this.project.addTestCompileSourceRoot(testOutputDirectory.getAbsolutePath());
    }
  }
}
 

Example 61

From project HBase-Lattice, under directory /sample/src/main/java/.

Source file: Example1.java

  16 
vote

private void runScript(String script,Path inputPath) throws IOException {
  try {
    PigContext pc=new PigContext();
    pc.setExecType(EXEC_TYPE);
    pc.getProperties().setProperty("pig.logfile","pig.log");
    pc.getProperties().setProperty(PigContext.JOB_NAME,"sample1-compiler-run");
    File[] jobJars=new File("target").listFiles(new FileFilter(){
      @Override public boolean accept(      File pathname){
        return pathname.getName().matches("sample-\\d+\\.\\d+\\.\\d+(-SNAPSHOT)?-hadoop-job.jar");
      }
    }
);
    if (jobJars == null || jobJars.length == 0)     throw new IOException("hadoop job jar was not found, please rebuild and run from $HBL_HOME/sample location..");
    for (    File f : jobJars)     pc.addJar(f.getAbsolutePath());
    ParameterSubstitutionPreprocessor psp=new ParameterSubstitutionPreprocessor(512);
    StringWriter sw=new StringWriter();
    BufferedReader br=new BufferedReader(new StringReader(script));
    psp.genSubstitutedFile(br,sw,new String[]{"input=" + inputPath},null);
    sw.close();
    script=sw.toString();
    sw=null;
    br=null;
    Grunt grunt=new Grunt(new BufferedReader(new StringReader(script)),pc);
    int[] codes=grunt.exec();
    int failed=codes[1];
    int succeeded=codes[0];
    System.out.printf("pig jobs failed:%d, pig jobs succeeded:%d.\n",failed,succeeded);
    if (failed != 0)     throw new IOException("Pig script execution failed, some jobs failed. Check the pig log for errors.");
  }
 catch (  Throwable thr) {
    if (thr instanceof IOException)     throw (IOException)thr;
    throw new IOException(thr);
  }
}
 

Example 62

From project hitchfs, under directory /hitchfs-test/src/test/java/gs/hitchin/hitchfs/.

Source file: MemoryFileSystemTest.java

  16 
vote

@Test public void testListFiles_FileFilter() throws IOException {
  FakeFile dir=fs.file("");
  dir.mkdirs();
  assertTrue(fs.file("d").createNewFile());
  FakeFile e=fs.file("e");
  assertTrue(e.createNewFile());
  assertTrue(e.delete());
  assertTrue(fs.file("f").createNewFile());
  assertTrue(fs.file("c").mkdir());
  File[] files=dir.listFiles(new FileFilter(){
    @Override public boolean accept(    File f){
      return !"d".equals(f.getName());
    }
  }
);
  assertEquals(2,files.length);
  assertEquals(fs.file("/c"),files[0]);
  assertEquals(fs.file("/f"),files[1]);
}
 

Example 63

From project Hphoto, under directory /src/test/com/hphoto/server/.

Source file: TestUpload.java

  16 
vote

public void testUpload() throws IOException {
  HashMap<String,CharSequence> map=new HashMap<String,CharSequence>();
  map.put("u","joshma");
  map.put("category","HytlOe");
  File[] file=(new File("./photo")).listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      String f=pathname.getName().toLowerCase();
      return f.endsWith("jpg");
    }
  }
);
  map.put("num",String.valueOf(file.length));
  InputStream in=postFileRequest(SERVER_URL,map,file);
  DataOutputStream out=new DataOutputStream(System.out);
  if (in != null) {
    byte b[]=new byte[UPLOAD_BUFFER_SIZE];
    int t;
    while (-1 != (t=in.read(b))) {
      out.write(b,0,t);
    }
  }
  out.close();
}
 

Example 64

From project huiswerk, under directory /print/zxing-1.6/javase/src/com/google/zxing/.

Source file: StringsResourceTranslator.java

  16 
vote

public static void main(String[] args) throws IOException {
  File resDir=new File(args[0]);
  File valueDir=new File(resDir,"values");
  File stringsFile=new File(valueDir,"strings.xml");
  Collection<String> forceRetranslation=Arrays.asList(args).subList(1,args.length);
  File[] translatedValuesDirs=resDir.listFiles(new FileFilter(){
    public boolean accept(    File file){
      return file.isDirectory() && file.getName().startsWith("values-");
    }
  }
);
  for (  File translatedValuesDir : translatedValuesDirs) {
    File translatedStringsFile=new File(translatedValuesDir,"strings.xml");
    translate(stringsFile,translatedStringsFile,forceRetranslation);
  }
}
 

Example 65

From project incubator-s4, under directory /subprojects/s4-core/src/main/java/org/apache/s4/core/ft/.

Source file: DefaultFileSystemStateStorage.java

  16 
vote

@Override public Set<CheckpointId> fetchStoredKeys(){
  Set<CheckpointId> keys=new HashSet<CheckpointId>();
  File rootDir=new File(storageRootPath);
  File[] dirs=rootDir.listFiles(new FileFilter(){
    @Override public boolean accept(    File file){
      return file.isDirectory();
    }
  }
);
  for (  File dir : dirs) {
    File[] files=dir.listFiles(new FileFilter(){
      @Override public boolean accept(      File file){
        return (file.isFile());
      }
    }
);
    for (    File file : files) {
      keys.add(file2CheckpointID(file));
    }
  }
  return keys;
}
 

Example 66

From project infinispan-arquillian-container, under directory /infinispan-container-managed/src/main/java/org/infinispan/arquillian/container/managed/.

Source file: InfinispanContainer.java

  16 
vote

private List<File> getJars(File startDir,boolean recursive) throws Exception {
  validateDirectory(startDir);
  List<File> result=new ArrayList<File>();
  File[] jars=startDir.listFiles(new FilenameFilter(){
    private Pattern jarZipPattern=Pattern.compile(".*\\.([Jj][Aa][Rr]|[Zz][Ii][Pp])$");
    public boolean accept(    File dir,    String name){
      Matcher jarZipMatcher=jarZipPattern.matcher(name);
      return jarZipMatcher.matches();
    }
  }
);
  List<File> jarList=Arrays.asList(jars);
  result.addAll(jarList);
  if (!recursive) {
    return result;
  }
  File[] dirs=startDir.listFiles(new FileFilter(){
    public boolean accept(    File file){
      return file.isDirectory() && file.canRead();
    }
  }
);
  for (  File file : dirs) {
    List<File> deeperList=getJars(file,true);
    result.addAll(deeperList);
  }
  return result;
}
 

Example 67

From project ios-driver, under directory /server/src/main/java/org/uiautomation/ios/server/application/.

Source file: LanguageDictionary.java

  16 
vote

/** 
 * @param aut the application under test. /A/B/C/xxx.app
 * @return the list of the folders hosting the l10ned files.
 * @throws IOSAutomationException
 */
public static List<File> getL10NFiles(File aut) throws IOSAutomationException {
  List<File> res=new ArrayList<File>();
  File[] files=aut.listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      return pathname.getName().endsWith("lproj");
    }
  }
);
  for (  File f : files) {
    File[] all=f.listFiles();
    for (    File potential : all) {
      if (potential.getAbsoluteFile().getAbsolutePath().endsWith(".strings")) {
        res.add(potential);
      }
    }
  }
  return res;
}
 

Example 68

From project jafka, under directory /src/main/java/com/sohu/jafka/log/.

Source file: Log.java

  16 
vote

private SegmentList loadSegments() throws IOException {
  List<LogSegment> accum=new ArrayList<LogSegment>();
  File[] ls=dir.listFiles(new FileFilter(){
    public boolean accept(    File f){
      return f.isFile() && f.getName().endsWith(FileSuffix);
    }
  }
);
  logger.info("loadSegments files from [" + dir.getAbsolutePath() + "]: "+ ls.length);
  int n=0;
  for (  File f : ls) {
    n++;
    String filename=f.getName();
    long start=Long.parseLong(filename.substring(0,filename.length() - FileSuffix.length()));
    final String logFormat="LOADING_LOG_FILE[%2d], start(offset)=%d, size=%d, path=%s";
    logger.info(String.format(logFormat,n,start,f.length(),f.getAbsolutePath()));
    FileMessageSet messageSet=new FileMessageSet(f,false);
    accum.add(new LogSegment(f,messageSet,start));
  }
  if (accum.size() == 0) {
    File newFile=new File(dir,Log.nameFromOffset(0));
    FileMessageSet fileMessageSet=new FileMessageSet(newFile,true);
    accum.add(new LogSegment(newFile,fileMessageSet,0));
  }
 else {
    Collections.sort(accum);
    validateSegments(accum);
  }
  LogSegment last=accum.remove(accum.size() - 1);
  last.getMessageSet().close();
  logger.info("Loading the last segment " + last.getFile().getAbsolutePath() + " in mutable mode, recovery "+ needRecovery);
  LogSegment mutable=new LogSegment(last.getFile(),new FileMessageSet(last.getFile(),true,new AtomicBoolean(needRecovery)),last.start());
  accum.add(mutable);
  return new SegmentList(name,accum);
}
 

Example 69

From project james-mailbox, under directory /maildir/src/main/java/org/apache/james/mailbox/maildir/mail/.

Source file: MaildirMailboxMapper.java

  16 
vote

private void visitUsersForMailboxList(File domain,File[] users,List<Mailbox<Integer>> mailboxList) throws MailboxException {
  String userName=null;
  for (  File user : users) {
    if (domain == null) {
      userName=user.getName();
    }
 else {
      userName=user.getName() + "@" + domain.getName();
    }
    MailboxPath inboxMailboxPath=new MailboxPath(session.getPersonalSpace(),userName,MailboxConstants.INBOX);
    mailboxList.add(maildirStore.loadMailbox(session,inboxMailboxPath));
    File[] mailboxes=user.listFiles(new FileFilter(){
      @Override public boolean accept(      File pathname){
        return pathname.getName().startsWith(".");
      }
    }
);
    for (    File mailbox : mailboxes) {
      MailboxPath mailboxPath=new MailboxPath(MailboxConstants.USER_NAMESPACE,userName,mailbox.getName().substring(1));
      mailboxList.add(maildirStore.loadMailbox(session,mailboxPath));
    }
  }
}
 

Example 70

From project javaparser, under directory /src/test/java/ignore/.

Source file: TestRunner.java

  16 
vote

private void visitAllJavaFiles(FileFilter callback,File dir){
  File[] listFiles=dir.listFiles(new FileFilter(){
    @Override public boolean accept(    File file){
      return file.isDirectory() || file.getName().endsWith(".java");
    }
  }
);
  if (listFiles != null) {
    for (    File element : listFiles) {
      if (element.isDirectory()) {
        visitAllJavaFiles(callback,element);
      }
 else {
        callback.accept(element);
      }
    }
  }
}
 

Example 71

From project jBilling, under directory /src/java/com/sapienter/jbilling/server/mediation/task/.

Source file: AbstractFileReader.java

  16 
vote

protected Reader() throws FileNotFoundException, IOException, SAXException {
  files=new File(directory).listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      if (suffix.equalsIgnoreCase("all") || pathname.getName().endsWith(suffix)) {
        return true;
      }
 else {
        return false;
      }
    }
  }
);
  Arrays.sort(files,new Comparator<File>(){
    public int compare(    File o1,    File o2){
      return new Long(o1.lastModified()).compareTo(o2.lastModified());
    }
  }
);
  if (!nextReader()) {
    LOG.info("No files found to process");
    format=null;
  }
 else {
    LOG.debug("Files to process = " + files.length);
    format=getFormat();
    counter=0;
    records=new ArrayList<Record>(getBatchSize());
  }
}
 

Example 72

From project jdcbot, under directory /src/org/elite/jdcbot/shareframework/.

Source file: HashManager.java

  16 
vote

private void hashDir(File dir){
  File files[]=dir.listFiles(new FileFilter(){
    public boolean accept(    File f){
      if (f.isFile())       return true;
 else       return false;
    }
  }
);
  if (files != null) {
    for (    File f : files) {
      if (cancel)       return;
      hashFile(f);
    }
  }
  File subdirs[]=dir.listFiles(new FileFilter(){
    public boolean accept(    File dir){
      if (dir.isDirectory())       return true;
 else       return false;
    }
  }
);
  if (subdirs != null)   hashDirs(subdirs);
}
 

Example 73

From project jSite, under directory /src/main/java/de/todesbaum/jsite/gui/.

Source file: FileScanner.java

  16 
vote

/** 
 * Recursively scans a directory and adds all found files to the given list.
 * @param rootDir The directory to scan
 * @param fileList The list to which to add the found files
 * @throws IOException if an I/O error occurs
 */
private void scanFiles(File rootDir,List<ScannedFile> fileList) throws IOException {
  File[] files=rootDir.listFiles(new FileFilter(){
    @Override @SuppressWarnings("synthetic-access") public boolean accept(    File file){
      return !project.isIgnoreHiddenFiles() || !file.isHidden();
    }
  }
);
  if (files == null) {
    throw new IOException(I18n.getMessage("jsite.file-scanner.can-not-read-directory"));
  }
  for (  File file : files) {
    if (file.isDirectory()) {
      scanFiles(file,fileList);
      continue;
    }
    String filename=project.shortenFilename(file).replace('\\','/');
    String hash=hashFile(project.getLocalPath(),filename);
    fileList.add(new ScannedFile(filename,hash));
    lastFilename=filename;
  }
}
 

Example 74

From project kabeja, under directory /blocks/svg/src/main/java/org/kabeja/batik/tools/.

Source file: FontImport.java

  16 
vote

public void importFonts(){
  File in=new File(source);
  File dest=new File(destination);
  if (!dest.exists()) {
    dest.mkdirs();
  }
  File[] files=in.listFiles(new FileFilter(){
    public boolean accept(    File f){
      if (f.getName().toLowerCase().endsWith(".ttf")) {
        return true;
      }
      return false;
    }
  }
);
  if (files.length > 0) {
    try {
      BufferedWriter out=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fontDescriptionFile,true)));
      for (int i=0; i < files.length; i++) {
        String fontFile=files[i].getName().toLowerCase();
        fontFile=fontFile.substring(0,fontFile.indexOf(".ttf"));
        File svgFont=new File(dest.getAbsolutePath() + File.separator + fontFile+ ".svg");
        importFont(files[i],svgFont,out);
      }
      out.flush();
      out.close();
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}
 

Example 75

From project Kairos, under directory /src/plugin/urlnormalizer-regex/src/test/org/apache/nutch/net/urlnormalizer/regex/.

Source file: TestRegexURLNormalizer.java

  16 
vote

public TestRegexURLNormalizer(String name) throws IOException {
  super(name);
  normalizer=new RegexURLNormalizer();
  conf=NutchConfiguration.create();
  normalizer.setConf(conf);
  File[] configs=new File(sampleDir).listFiles(new FileFilter(){
    public boolean accept(    File f){
      if (f.getName().endsWith(".xml") && f.getName().startsWith("regex-normalize-"))       return true;
      return false;
    }
  }
);
  for (int i=0; i < configs.length; i++) {
    try {
      FileInputStream fis=new FileInputStream(configs[i]);
      String cname=configs[i].getName();
      cname=cname.substring(16,cname.indexOf(".xml"));
      normalizer.setConfiguration(fis,cname);
      NormalizedURL[] urls=readTestFile(cname);
      testData.put(cname,urls);
    }
 catch (    Exception e) {
      LOG.warn("Could load config from '" + configs[i] + "': "+ e.toString());
    }
  }
}
 

Example 76

From project kernel_1, under directory /exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/.

Source file: ExoExpression.java

  16 
vote

private List<File> listFile(File dir){
  final List<File> list=new ArrayList<File>();
  if (dir.isFile()) {
    list.add(dir);
    return list;
  }
  dir.listFiles(new FileFilter(){
    public boolean accept(    File f){
      if (f.isDirectory())       list.addAll(listFile(f));
      list.add(f);
      return true;
    }
  }
);
  return list;
}
 

Example 77

From project krati, under directory /krati-main/src/main/java/krati/core/segment/.

Source file: SegmentManager.java

  16 
vote

/** 
 * Lists all the segment files managed by this SegmentManager. 
 */
protected File[] listSegmentFiles(){
  File segDir=new File(_segHomePath);
  File[] segFiles=segDir.listFiles(new FileFilter(){
    @Override public boolean accept(    File filePath){
      String fileName=filePath.getName();
      if (fileName.matches("^[0-9]+\\.seg$")) {
        return true;
      }
      return false;
    }
  }
);
  if (segFiles == null) {
    segFiles=new File[0];
  }
 else   if (segFiles.length > 0) {
    Arrays.sort(segFiles,new Comparator<File>(){
      @Override public int compare(      File f1,      File f2){
        int segId1=Integer.parseInt(f1.getName().substring(0,f1.getName().indexOf('.')));
        int segId2=Integer.parseInt(f2.getName().substring(0,f2.getName().indexOf('.')));
        return (segId1 < segId2) ? -1 : ((segId1 == segId2) ? 0 : 1);
      }
    }
);
  }
  return segFiles;
}
 

Example 78

From project libra, under directory /plugins/org.eclipse.libra.framework.core/src/org/eclipse/libra/framework/core/.

Source file: OSGIFrameworkLocatorDelegate.java

  16 
vote

protected static void searchDir(IRuntimeSearchListener listener,File dir,int depth,IProgressMonitor monitor){
  if ("conf".equals(dir.getName())) {
    IRuntimeWorkingCopy runtime=getRuntimeFromDir(dir.getParentFile(),monitor);
    if (runtime != null) {
      listener.runtimeFound(runtime);
      return;
    }
  }
  if (depth == 0)   return;
  File[] files=dir.listFiles(new FileFilter(){
    public boolean accept(    File file){
      return file.isDirectory();
    }
  }
);
  if (files != null) {
    int size=files.length;
    for (int i=0; i < size; i++) {
      if (monitor.isCanceled())       return;
      searchDir(listener,files[i],depth - 1,monitor);
    }
  }
}
 

Example 79

From project liquibase, under directory /liquibase-integration-tests/src/test/java/liquibase/test/.

Source file: JUnitJDBCDriverClassLoader.java

  16 
vote

private static void addUrlsFromPath(List<URL> addTo,String path) throws Exception {
  File thisClassFile=new File(new URI(Thread.currentThread().getContextClassLoader().getResource("liquibase/test/JUnitJDBCDriverClassLoader.class").toExternalForm()));
  File jdbcLib=new File(thisClassFile.getParentFile().getParentFile().getParentFile(),path);
  if (!jdbcLib.exists()) {
    throw new RuntimeException("JDBC driver directory " + jdbcLib.getAbsolutePath() + " does not exist");
  }
  File[] files=jdbcLib.listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      return pathname.isDirectory();
    }
  }
);
  if (files == null) {
    files=new File[]{};
  }
  for (  File driverDir : files) {
    File[] driverJars=driverDir.listFiles(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.endsWith("jar");
      }
    }
);
    for (    File jar : driverJars) {
      addTo.add(jar.toURL());
    }
  }
}
 

Example 80

From project m2e-core-tests, under directory /org.eclipse.m2e.tests/src/org/eclipse/m2e/tests/conversion/.

Source file: ProjectConversionTest.java

  16 
vote

public void testProjectConversionWithSvn() throws Exception {
  String projectName="custom-layout";
  deleteProject(projectName);
  String srcDir="projects/conversion/" + projectName;
  IProject project=createExisting(projectName,srcDir);
  assertTrue(projectName + " was not created!",project.exists());
  assertNoErrors(project);
  String svnDir="JavaSource/foo/.svn";
  FileHelpers.copyDir(new File(srcDir,svnDir),project.getFolder(svnDir).getLocation().toFile(),new FileFilter(){
    public boolean accept(    File pathname){
      return true;
    }
  }
);
  project.refreshLocal(IResource.DEPTH_INFINITE,monitor);
  waitForJobsToComplete();
  assertTrue(project.getFolder(svnDir).getFile("hidden/index.properties").exists());
  assertConvertsAndBuilds(project);
}
 

Example 81

From project Maimonides, under directory /src/com/codeko/apps/maimonides/digitalizacion/.

Source file: Digitalizador.java

  16 
vote

public ArrayList<File> getArchivos(){
  if (archivos == null) {
    archivos=new ArrayList<File>();
    File[] arch=getCarpetaGeneralPartes().listFiles(new FileFilter(){
      @Override public boolean accept(      File pathname){
        return pathname.isFile() && pathname.getName().toLowerCase().endsWith("." + ConfiguracionParte.getConfiguracion().getExtensionImagenes());
      }
    }
);
    if (arch != null) {
      archivos.addAll(Arrays.asList(arch));
    }
  }
  return archivos;
}
 

Example 82

From project AdminCmd, under directory /src/main/java/be/Balor/Importer/.

Source file: SubDirFileFilter.java

  15 
vote

/** 
 * Returns a List<File> of all Dirs/Files depending on the filter. If recursive is set to true it will get dirs/files in sub-diretories too.
 * @param basedir
 * @param filter
 * @param recursive
 * @return A list of files and/or directories matching the input pattern
 */
public final List<File> getFiles(final File basedir,final FileFilter filter,boolean recursive){
  List<File> files=new ArrayList<File>();
  if (basedir != null && basedir.isDirectory()) {
    if (recursive)     for (    File subdir : basedir.listFiles())     files.addAll(this.getFiles(subdir,filter,recursive));
    files.addAll(Arrays.asList(basedir.listFiles(filter)));
  }
  return files;
}
 

Example 83

From project BibleQuote-for-Android, under directory /src/com/BibleQuote/dal/.

Source file: FsLibraryContext.java

  15 
vote

/** 
 * ????????? ????? ????? ? ???????? ?????? ?? ??????? ???????? ??????????
 * @return ?????????? ArrayList ?? ??????? ini-?????? ???????
 */
public ArrayList<String> SearchModules(FileFilter filter){
  Log.i(TAG,"SearchModules()");
  ArrayList<String> iniFiles=new ArrayList<String>();
  if (!isLibraryExist()) {
    return iniFiles;
  }
  try {
    FsUtils.SearchByFilter(libraryDir,iniFiles,filter);
  }
 catch (  Exception e) {
    Log.e(TAG,"SearchModules()",e);
    return iniFiles;
  }
  return iniFiles;
}
 

Example 84

From project cloudhopper-commons-util, under directory /src/main/java/com/cloudhopper/commons/util/filefilter/.

Source file: CompositeFileFilter.java

  15 
vote

@Override public boolean accept(File file){
  for (  FileFilter filter : filters) {
    if (!filter.accept(file)) {
      return false;
    }
  }
  return true;
}
 

Example 85

From project collector, under directory /src/main/java/com/ning/metrics/collector/hadoop/processing/.

Source file: LocalSpoolManager.java

  15 
vote

public static Collection<File> findOldSpoolDirectories(final String basePath,final long cutoff){
  final Collection<File> files=new java.util.LinkedList<File>();
  final File[] found=new File(basePath).listFiles((FileFilter)FileFilterUtils.and(FileFilterUtils.directoryFileFilter(),FileFilterUtils.ageFileFilter(System.currentTimeMillis() - cutoff,true)));
  if (found != null) {
    for (    final File file : found) {
      if (file.isDirectory()) {
        files.add(file);
      }
    }
  }
  return files;
}
 

Example 86

From project commons-io, under directory /src/main/java/org/apache/commons/io/filefilter/.

Source file: DelegateFileFilter.java

  15 
vote

/** 
 * Constructs a delegate file filter around an existing FileFilter.
 * @param filter  the filter to decorate
 */
public DelegateFileFilter(FileFilter filter){
  if (filter == null) {
    throw new IllegalArgumentException("The FileFilter must not be null");
  }
  this.fileFilter=filter;
  this.filenameFilter=null;
}
 

Example 87

From project community-plugins, under directory /deployit-cli-plugins/mustachifier/src/main/java/ext/deployit/community/cli/mustachify/io/.

Source file: Files2.java

  15 
vote

private static void innerListFiles(Collection<File> files,File directory,IOFileFilter filter,boolean includeDirs){
  File[] found=directory.listFiles((FileFilter)filter);
  if (found != null) {
    for (int i=0; i < found.length; i++) {
      boolean isDir=found[i].isDirectory();
      if (!isDir || includeDirs) {
        files.add(found[i]);
      }
      if (isDir) {
        innerListFiles(files,found[i],filter,includeDirs);
      }
    }
  }
}
 

Example 88

From project dawn-isencia, under directory /com.isencia.passerelle.commons/src/main/java/com/isencia/util/.

Source file: ClassPath.java

  15 
vote

/** 
 * DOCUMENT ME!
 * @param dir DOCUMENT ME!
 * @return DOCUMENT ME!
 */
private String buildClassPath(String dir,FileFilter filter){
  StringBuffer classPath=new StringBuffer();
  File lib=new File(dir);
  File[] libFiles=lib.listFiles(filter);
  if (libFiles == null)   return classPath.toString();
  for (int i=0; i < libFiles.length; i++) {
    if (libFiles[i].isDirectory()) {
      classPath.append(buildClassPath(libFiles[i].getPath(),filter));
    }
 else {
      classPath.append("'" + libFiles[i].getPath() + "'"+ File.pathSeparator);
    }
  }
  return classPath.toString();
}
 

Example 89

From project flexmojos, under directory /flexmojos-maven-plugin/src/main/java/net/flexmojos/oss/plugin/source/.

Source file: SourceViewMojo.java

  15 
vote

/** 
 * Loop through source files in the directory and syntax highlight and/or copy them to the target directory.
 * @param directory The source directory to process.
 * @param targetDirectory The directory where to store the output.
 */
protected void processDirectory(File directory,File targetDirectory){
  getLog().debug("Processing directory " + directory.getName());
  for (  File file : directory.listFiles((FileFilter)filter)) {
    if (!file.isHidden() && !file.getName().startsWith(".")) {
      if (file.isDirectory()) {
        File newTargetDirectory=new File(targetDirectory,file.getName());
        newTargetDirectory.mkdir();
        processDirectory(file,newTargetDirectory);
      }
 else {
        try {
          processFile(file,targetDirectory);
        }
 catch (        IOException e) {
          getLog().warn("Error while processing " + file.getName(),e);
        }
      }
    }
  }
}
 

Example 90

From project Game_3, under directory /html/src/playn/rebind/.

Source file: AutoClientBundleGenerator.java

  15 
vote

/** 
 * Recursively get a list of files in the provided directory.
 */
private HashSet<File> getFiles(File dir,FileFilter filter){
  Asserts.checkNotNull(dir);
  Asserts.checkNotNull(filter);
  Asserts.checkArgument(dir.isDirectory());
  HashSet<File> fileList=new HashSet<File>();
  File[] files=dir.listFiles(filter);
  for (int i=0; i < files.length; i++) {
    File f=files[i];
    if (f.isFile()) {
      fileList.add(f);
    }
 else {
      if (filter.accept(f)) {
        fileList.addAll(getFiles(f,filter));
      }
    }
  }
  return fileList;
}
 

Example 91

From project jboss-vfs, under directory /src/test/java/org/jboss/test/vfs/support/.

Source file: ClassPathIterator.java

  15 
vote

FileIterator(File start,FileFilter filter){
  String name=start.getName();
  boolean isWar=name.endsWith(".war");
  if (isWar)   currentListing=new File[0];
 else   currentListing=start.listFiles(filter);
  this.filter=filter;
}
 

Example 92

From project jmd, under directory /src/org/apache/commons/io/filefilter/.

Source file: DelegateFileFilter.java

  15 
vote

/** 
 * Constructs a delegate file filter around an existing FileFilter.
 * @param filter  the filter to decorate
 */
public DelegateFileFilter(FileFilter filter){
  if (filter == null) {
    throw new IllegalArgumentException("The FileFilter must not be null");
  }
  this.fileFilter=filter;
  this.filenameFilter=null;
}
 

Example 93

From project jnr-posix, under directory /src/org/jruby/ext/posix/.

Source file: JavaSecuredFile.java

  15 
vote

@Override public File[] listFiles(FileFilter filter){
  try {
    return super.listFiles(filter);
  }
 catch (  SecurityException ex) {
    return null;
  }
}
 

Example 94

From project JoSQL, under directory /src/main/java/com/gentlyweb/utils/.

Source file: FileWatcher.java

  15 
vote

/** 
 * Add all the files in the specified directory.  Use the FileFilter to provide filtering of files that we don't want to add.  If the filter is null then we just add all the files.  If <b>dir</b> points to a file then we do nothing.
 * @param dir The directory.
 * @param ff The FileFilter to use to determine which files to accept/reject.
 */
public void addAll(File dir,FileFilter ff){
  if (!dir.isDirectory()) {
    return;
  }
  if (!dir.canRead()) {
    return;
  }
  File files[]=dir.listFiles();
  for (int i=0; i < files.length; i++) {
    if (this.files.containsKey(files[i])) {
      continue;
    }
    if (ff == null) {
      this.files.put(files[i],new FileDetails(files[i]));
    }
 else {
      if (ff.accept(files[i])) {
        this.files.put(files[i],new FileDetails(files[i]));
      }
    }
  }
}
 

Example 95

From project karaf, under directory /tooling/exam/container/src/main/java/org/apache/karaf/tooling/exam/container/internal/.

Source file: KarafTestContainer.java

  15 
vote

private String[] buildKarafClasspath(File karafHome){
  List<String> cp=new ArrayList<String>();
  File[] jars=new File(karafHome + "/lib").listFiles((FileFilter)new WildcardFileFilter("*.jar"));
  for (  File jar : jars) {
    cp.add(jar.toString());
  }
  return cp.toArray(new String[]{});
}
 

Example 96

From project labs-paxexam-karaf, under directory /container/src/main/java/org/openengsb/labs/paxexam/karaf/container/internal/.

Source file: KarafTestContainer.java

  15 
vote

private String[] buildKarafClasspath(File karafHome){
  List<String> cp=new ArrayList<String>();
  File[] jars=new File(karafHome + "/lib").listFiles((FileFilter)new WildcardFileFilter("*.jar"));
  for (  File jar : jars) {
    cp.add(jar.toString());
  }
  return cp.toArray(new String[]{});
}
 

Example 97

From project maven-cxx-plugin, under directory /src/main/java/org/hardisonbrewing/maven/cxx/qnx/.

Source file: PreparePackageMojo.java

  15 
vote

@Override public void execute() throws MojoExecutionException, MojoFailureException {
  BarDescriptor barDescriptor=BarDescriptorService.getBarDescriptor();
  if (barDescriptor != null) {
    String barFilePath=TargetDirectoryService.getBarPath(barDescriptor);
    org.hardisonbrewing.maven.cxx.generic.PreparePackageMojo.prepareTargetFile(barFilePath);
    return;
  }
  for (  File file : TargetDirectoryService.getMakefileDirectories()) {
    String variant=file.getName();
    boolean staticLib=variant.matches(".*[\\.]?a[\\.]?.*");
    if (!staticLib) {
      continue;
    }
    String cpu=file.getParentFile().getName();
    File[] staticLibFiles=file.listFiles((FileFilter)new WildcardFileFilter("lib*.a"));
    for (    File staticLibFile : staticLibFiles) {
      String filename=cpu + File.separator + staticLibFile.getName();
      org.hardisonbrewing.maven.cxx.generic.PreparePackageMojo.prepareTargetFile(staticLibFile,filename);
    }
  }
}