Java Code Examples for java.io.FilenameFilter

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 community-plugins, under directory /deployit-server-plugins/importers/single-file-importer/src/main/java/ext/deployit/community/importer/singlefile/.

Source file: SingleFileImporter.java

  18 
vote

@Override public List<String> list(File directory){
  FilenameFilter supportedFileFilter=new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      File file=new File(dir,name);
      return file.isFile() && isSupportedFile(file);
    }
  }
;
  List<String> supportedFiles=scanSubdirectories ? listRecursively(directory,supportedFileFilter) : newArrayList(directory.list(supportedFileFilter));
  sort(supportedFiles);
  LOGGER.debug("Found supported files in package directory: {}",supportedFiles);
  return supportedFiles;
}
 

Example 2

From project gxa, under directory /atlas-utils/src/test/java/uk/ac/ebi/gxa/utils/.

Source file: FileUtilTest.java

  18 
vote

@Test public void testBinaries(){
  final FilenameFilter filter=extension("nc",false);
  assertTrue("Proper filename",filter.accept(null,"test.nc"));
  assertFalse("Unwanted .txt",filter.accept(null,"test.nc.txt"));
  assertFalse("Different extension",filter.accept(null,"test.nc1"));
}
 

Example 3

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

Source file: Certifications.java

  18 
vote

private String[] getFilesWithName(final String name){
  File dlPath=new File(mPreferences.getString("downloadPathPref",defaultDLPath));
  FilenameFilter filter=new FilenameFilter(){
    @Override public boolean accept(    File dir,    String filename){
      if (filename.startsWith(name)) {
        return true;
      }
      return false;
    }
  }
;
  return dlPath.list(filter);
}
 

Example 4

From project kuromoji, under directory /src/main/java/org/atilika/kuromoji/util/.

Source file: TokenInfoDictionaryBuilder.java

  18 
vote

public TokenInfoDictionary build(String dirname) throws IOException {
  FilenameFilter filter=new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.endsWith(".csv");
    }
  }
;
  ArrayList<File> csvFiles=new ArrayList<File>();
  for (  File file : new File(dirname).listFiles(filter)) {
    csvFiles.add(file);
  }
  return buildDictionary(csvFiles);
}
 

Example 5

From project logback, under directory /logback-core/src/test/java/ch/qos/logback/core/rolling/.

Source file: MultiThreadedRollingTest.java

  18 
vote

int testFileCount(){
  File outputDir=new File(outputDirStr);
  FilenameFilter filter=new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      if (name.matches("test-\\d{1,2}.log")) {
        return true;
      }
      return false;
    }
  }
;
  File[] files=outputDir.listFiles(filter);
  return files.length;
}
 

Example 6

From project akubra, under directory /akubra-www/src/test/java/org/akubraproject/www/.

Source file: WWWTCKTest.java

  17 
vote

private String[] listFiles(String prefix) throws Exception {
  if (prefix == null || prefix.equals(""))   return new String[0];
  final File f=new File(new URI(prefix));
  return f.getParentFile().list(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.startsWith(f.getName());
    }
  }
);
}
 

Example 7

From project ALP, under directory /workspace/alp-utils/src/main/java/com/lohika/alp/utils/json/validator/.

Source file: ALPJSONValidator.java

  17 
vote

/** 
 * Instantiates a new ALPJSON validator.
 * @param JSONSchemasPath - represent path to folder with all schemas
 * @param in_schemaName the in_schema name
 * @throws IOException Signals that an I/O exception has occurred.
 */
public ALPJSONValidator(String JSONSchemasPath,String in_schemaName) throws IOException {
  schemaName=in_schemaName;
  JSONFactory=new JsonFactory();
  JSONStack=new LinkedList<String>();
  ErrorsStack=new LinkedList<String>();
  first_try=true;
  JSONMapper=new ObjectMapper();
  File dir=new File(JSONSchemasPath);
  FilenameFilter jsonFilter=new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.toLowerCase().endsWith(".json");
    }
  }
;
  schemasList=dir.listFiles(jsonFilter);
}
 

Example 8

From project Android-MapForgeFragment, under directory /library-common/src/com/jakewharton/android/mapsforge_fragment/.

Source file: TileMemoryCardCache.java

  17 
vote

/** 
 * Deletes all cached files and the cache directory itself.
 */
private void deleteCachedFiles(){
  if (this.map != null) {
    for (    File file : this.map.values()) {
      if (!file.delete()) {
        file.deleteOnExit();
      }
    }
    this.map.clear();
    this.map=null;
  }
  if (this.tempDir != null && this.tempDir.isDirectory()) {
    FilenameFilter filenameFilter=new FilenameFilter(){
      @Override public boolean accept(      File dir,      String name){
        return name.endsWith(IMAGE_FILE_NAME_EXTENSION);
      }
    }
;
    for (    File file : this.tempDir.listFiles(filenameFilter)) {
      if (!file.delete()) {
        file.deleteOnExit();
      }
    }
    if (this.tempDir != null && !this.tempDir.delete()) {
      this.tempDir.deleteOnExit();
    }
  }
}
 

Example 9

From project android-tether, under directory /src/og/android/tether/system/.

Source file: CoreTask.java

  17 
vote

public boolean isProcessRunning(String processName) throws Exception {
  boolean processIsRunning=false;
  Hashtable<String,String> tmpRunningProcesses=new Hashtable<String,String>();
  File procDir=new File("/proc");
  FilenameFilter filter=new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      try {
        Integer.parseInt(name);
      }
 catch (      NumberFormatException ex) {
        return false;
      }
      return true;
    }
  }
;
  File[] processes=procDir.listFiles(filter);
  for (  File process : processes) {
    String cmdLine="";
    if (this.runningProcesses.containsKey(process.getAbsoluteFile().toString())) {
      cmdLine=this.runningProcesses.get(process.getAbsoluteFile().toString());
    }
 else {
      ArrayList<String> cmdlineContent=this.readLinesFromFile(process.getAbsoluteFile() + "/cmdline");
      if (cmdlineContent != null && cmdlineContent.size() > 0) {
        cmdLine=cmdlineContent.get(0);
      }
    }
    tmpRunningProcesses.put(process.getAbsoluteFile().toString(),cmdLine);
    if (cmdLine.contains(processName)) {
      processIsRunning=true;
    }
  }
  this.runningProcesses=tmpRunningProcesses;
  return processIsRunning;
}
 

Example 10

From project ant4eclipse, under directory /org.ant4eclipse.lib.core/src/org/ant4eclipse/lib/core/util/.

Source file: Utilities.java

  17 
vote

public static final File getChild(File directory,final String childName){
  File[] children=directory.listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.equals(childName);
    }
  }
);
  if (children.length < 1) {
    return null;
  }
  return children[0];
}
 

Example 11

From project apollo, under directory /injector/src/main/java/com/bskyb/cg/environments/hash/.

Source file: PersistentHash.java

  17 
vote

private synchronized void refreshFromStore(String dirname) throws IOException {
  FileInputStream fis;
  BufferedInputStream bis;
  Serializable messageEntry;
  ObjectInputStream ois;
  File emptyDir=new File(dirname);
  FilenameFilter onlyDat=new FileExtFilter(STOREFILEEXT);
  File[] files=emptyDir.listFiles(onlyDat);
  hash.clear();
  for (  File file : files) {
    fis=new FileInputStream(file);
    bis=new BufferedInputStream(fis);
    ois=new ObjectInputStream(bis);
    try {
      messageEntry=(Serializable)ois.readObject();
    }
 catch (    ClassNotFoundException e) {
      throw new IOException(e.toString());
    }
catch (    ClassCastException e) {
      throw new IOException(e.toString());
    }
catch (    StreamCorruptedException e) {
      throw new IOException(e.toString());
    }
    try {
      hash.put(file.getName(),(Message)messageEntry);
    }
 catch (    ClassCastException e) {
      throw new IOException(e.toString());
    }
    fis.close();
  }
}
 

Example 12

From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/ingest/.

Source file: IngestModuleLoader.java

  17 
vote

private Set<URL> getJarPaths(String modulesDir){
  Set<URL> urls=new HashSet<URL>();
  final File modulesDirF=new File(modulesDir);
  FilenameFilter jarFilter=new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return dir.equals(modulesDirF) && name.endsWith(".jar");
    }
  }
;
  File[] dirJars=modulesDirF.listFiles(jarFilter);
  if (dirJars != null) {
    for (int i=0; i < dirJars.length; ++i) {
      String urlPath="file:/" + dirJars[i].getAbsolutePath();
      try {
        urlPath=URLDecoder.decode(urlPath,ENCODING);
      }
 catch (      UnsupportedEncodingException ex) {
        logger.log(Level.SEVERE,"Could not decode file path. ",ex);
      }
      try {
        urls.add(new URL(urlPath));
        logger.log(Level.INFO,"JAR: " + urlPath);
      }
 catch (      MalformedURLException ex) {
        logger.log(Level.WARNING,"Invalid URL: " + urlPath,ex);
      }
    }
  }
  return urls;
}
 

Example 13

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

Source file: LatkeClient.java

  17 
vote

/** 
 * Gets the backup files under a backup specified directory by the given repository name.
 * @param repositoryName the given repository name
 * @return backup files, returns an empty set if not found
 */
private static Set<File> getBackupFiles(final String repositoryName){
  final String backupRepositoryPath=backupDir.getPath() + File.separatorChar + repositoryName+ File.separatorChar;
  final File[] repositoryDataFiles=new File(backupRepositoryPath).listFiles(new FilenameFilter(){
    @Override public boolean accept(    final File dir,    final String name){
      return name.endsWith(".json");
    }
  }
);
  final Set<File> ret=new HashSet<File>();
  for (int i=0; i < repositoryDataFiles.length; i++) {
    ret.add(repositoryDataFiles[i]);
  }
  return ret;
}
 

Example 14

From project BHT-FPA, under directory /mailer-common/de.bht.fpa.mail.common/src/de/bht/fpa/mail/s000000/common/mail/testdata/.

Source file: FileSystemTestDataProvider.java

  17 
vote

private FilenameFilter filteredByXMLFiles(){
  return new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.endsWith("xml");
    }
  }
;
}
 

Example 15

From project Cafe, under directory /webapp/src/org/openqa/selenium/browserlaunchers/locators/.

Source file: Firefox3Locator.java

  17 
vote

/** 
 * Dynamic because the directory version number keep changing.
 */
protected String[] firefoxDefaultLocationsOnUbuntu(){
  final File dir;
  dir=new File(UBUNTU_BASE_DIR);
  if (!dir.exists() && dir.isDirectory()) {
    return new String[]{};
  }
  return dir.list(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.startsWith("firefox-");
    }
  }
);
}
 

Example 16

From project Catroid-maven-playground, under directory /src/main/java/at/tugraz/ist/catroid/utils/.

Source file: UtilFile.java

  17 
vote

/** 
 * returns a list of strings of all projectnames in the catroid folder
 */
public static List<String> getProjectNames(File directory){
  List<String> projectList=new ArrayList<String>();
  File[] sdFileList=directory.listFiles();
  for (  File file : sdFileList) {
    FilenameFilter filenameFilter=new FilenameFilter(){
      public boolean accept(      File dir,      String filename){
        return filename.contentEquals(Constants.PROJECTCODE_NAME);
      }
    }
;
    if (file.isDirectory() && file.list(filenameFilter).length != 0) {
      projectList.add(file.getName());
    }
  }
  return projectList;
}
 

Example 17

From project cb2java, under directory /src/test/java/net/sf/cb2java/copybook/.

Source file: CopybooksTest.java

  17 
vote

/** 
 * Test of readCopybooks method, of class Copybooks.
 */
public void testReadCopybooks_FileArr() throws Exception {
  Map<String,Copybook> copybooks=readCopybooks(new File("./target/test-classes/").listFiles(new FilenameFilter(){
    @Override public boolean accept(    File file,    String filename){
      return filename.endsWith(".copybook");
    }
  }
));
  assertEquals(3,copybooks.size());
  assertTrue(copybooks.containsKey("a"));
  assertTrue(copybooks.containsKey("b"));
}
 

Example 18

From project ceres, under directory /ceres-core/src/test/java/com/bc/ceres/core/runtime/internal/.

Source file: ModuleScannerTest.java

  17 
vote

private static URL[] getDirEntryUrls(File modulesDir) throws MalformedURLException {
  String[] dirs=new DirScanner(modulesDir).scan(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return true;
    }
  }
);
  URL[] urls=new URL[dirs.length];
  for (int i=0; i < dirs.length; i++) {
    urls[i]=new File(modulesDir,dirs[i]).toURI().toURL();
  }
  return urls;
}
 

Example 19

From project cilia-workbench, under directory /cilia-workbench-designer/src/fr/liglab/adele/cilia/workbench/designer/service/common/.

Source file: AbstractRepoService.java

  17 
vote

/** 
 * Gets files list of the physical repository.
 * @return the files
 */
protected File[] getFiles(){
  File dir=getRepositoryLocation();
  if (dir == null)   return new File[0];
  File[] list=dir.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.toLowerCase().endsWith(ext);
    }
  }
);
  if (list == null)   return new File[0];
 else   return list;
}
 

Example 20

From project Cloud9, under directory /src/integration/edu/umd/cloud9/integration/.

Source file: IntegrationUtils.java

  17 
vote

public static String getJar(String path,final String prefix){
  File[] arr=new File(path).listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.startsWith(prefix) && !name.contains("javadoc") && !name.contains("sources");
    }
  }
);
  assertTrue(arr.length == 1);
  return arr[0].getAbsolutePath();
}
 

Example 21

From project craftbook, under directory /mechanisms/src/main/java/com/sk89q/craftbook/bukkit/commands/.

Source file: AreaCommands.java

  17 
vote

private boolean deleteDir(File dir){
  final MechanismsConfiguration.AreaSettings config=plugin.getLocalConfiguration().areaSettings;
  FilenameFilter fnf=new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return config.useSchematics ? name.endsWith(".schematic") : name.endsWith(".cbcopy");
    }
  }
;
  if (dir.isDirectory()) {
    for (    File aChild : dir.listFiles(fnf)) {
      if (!aChild.delete())       return false;
    }
  }
  return dir.delete();
}
 

Example 22

From project cxf-dosgi, under directory /systests/single_bundle_distro/src/test/java/org/apache/cxf/dosgi/systests/singlebundle/.

Source file: SingleBundleDistributionResolver.java

  17 
vote

static File[] getDistribution() throws Exception {
  File distroRoot=new File(System.getProperty("basedir") + "/../../distribution/single-bundle").getCanonicalFile();
  return new File(distroRoot,"target").listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.startsWith("cxf-dosgi-ri-singlebundle-distribution") && name.endsWith(".jar");
    }
  }
);
}
 

Example 23

From project dawn-isencia, under directory /com.isencia.passerelle.engine/src/main/java/com/isencia/passerelle/model/.

Source file: FlowManager.java

  17 
vote

/** 
 * Finds flow resources on the given base location, and constructs FlowHandle instances for them. <br/> From these FlowHandles, the full flow can be constructed. <br/> In this way, we can implement a lazy-loading approach for Flows. <p> If the URL points to a local location, it should be a folder on a local disk. Alternatively it can be a REST URL pointing to a Passerelle Manager. A sample REST URL is in the form of :<br/> http://localhost:8080/passerelle-manager/bridge/PasserelleManagerService/ V1.0/jobs/ </p>
 * @param baseResourceLocation
 * @return
 * @throws PasserelleException
 */
public static Collection<FlowHandle> getFlowsFromResourceLocation(URL baseResourceLocation) throws PasserelleException {
  if (baseResourceLocation == null) {
    return null;
  }
  Collection<FlowHandle> results=null;
  String protocol=baseResourceLocation.getProtocol();
  if ("http".equals(protocol) || "https".equals(protocol)) {
    if (restFacade == null) {
      initRESTFacade();
    }
    results=restFacade.getAllRemoteFlowHandles(baseResourceLocation);
  }
 else   if ("file".equals(protocol)) {
    results=new ArrayList<FlowHandle>();
    try {
      File dir=new File(baseResourceLocation.toURI());
      if (dir != null && dir.exists()) {
        FilenameFilter filter=new FilenameFilter(){
          public boolean accept(          File file,          String name){
            return name.endsWith(".moml");
          }
        }
;
        File[] fileList=dir.listFiles(filter);
        for (        File file : fileList) {
          FlowHandle flowHandle=new FlowHandle(null,file.getName(),file.toURL());
          results.add(flowHandle);
        }
      }
    }
 catch (    Exception e) {
      throw new PasserelleException("Error reading flows from " + baseResourceLocation,null,e);
    }
  }
  return results != null ? results : new ArrayList<FlowHandle>();
}
 

Example 24

From project dolphin, under directory /com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/.

Source file: Tomcat3Bootstrap.java

  17 
vote

protected String[] addJarsOfDirectory(String[] previous,File dir){
  if ((dir != null) && (dir.isDirectory())) {
    FilenameFilter filter=new FilenameFilter(){
      public boolean accept(      File dir,      String filename){
        return filename.endsWith(".jar");
      }
    }
;
    String[] jars=null;
    File[] files=dir.listFiles(filter);
    jars=new String[files.length];
    for (int i=0; i < files.length; i++)     jars[i]=files[i].getAbsolutePath();
    return StringUtil.concat(previous,jars);
  }
 else {
    return previous;
  }
}
 

Example 25

From project e4-rendering, under directory /com.toedter.e4.demo.contacts.generic/src/com/toedter/e4/demo/contacts/generic/model/internal/.

Source file: VCardContactsRepository.java

  17 
vote

private File[] getLocalContacts(){
  IPath path=BundleActivatorImpl.getInstance().getStateLocation();
  File directory=path.toFile();
  return directory.listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(".vcf");
    }
  }
);
}
 

Example 26

From project eclim, under directory /org.eclim.installer/java/org/eclim/installer/step/.

Source file: EclipseUtils.java

  17 
vote

public static String findEclipseLauncherJar(String eclipseHome){
  String plugins=eclipseHome + "/plugins";
  String[] results=new File(plugins).list(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.startsWith(LAUNCHER_PREFIX) && name.endsWith(".jar");
    }
  }
);
  if (results != null && results.length > 0) {
    return FilenameUtils.concat(plugins,results[0]);
  }
  return null;
}
 

Example 27

From project eclipse.pde.build, under directory /org.eclipse.pde.build.tests/src/org/eclipse/pde/build/internal/tests/p2/.

Source file: PublishingTests.java

  17 
vote

protected File findExecutableFeature(File delta) throws Exception {
  FilenameFilter filter=new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.startsWith(EQUINOX_EXECUTABLE);
    }
  }
;
  File[] features=new File(delta,"features").listFiles(filter);
  assertTrue(features.length > 0);
  Arrays.sort(features,new Comparator(){
    public int compare(    Object o1,    Object o2){
      return -1 * ((File)o1).getName().compareTo(((File)o2).getName());
    }
  }
);
  return features[0];
}
 

Example 28

From project etherpad, under directory /infrastructure/rhino1_7R1/src/org/mozilla/javascript/.

Source file: RhinoException.java

  17 
vote

/** 
 * Get a string representing the script stack of this exception. If optimization is enabled, this corresponds to all java stack elements with a source name ending with ".js".
 * @return a script stack dump
 * @since 1.6R6
 */
public String getScriptStackTrace(){
  return getScriptStackTrace(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(".js");
    }
  }
);
}
 

Example 29

From project FBReaderJ, under directory /src/org/geometerplus/zlibrary/ui/android/view/.

Source file: AndroidFontUtil.java

  17 
vote

private static Map<String,File[]> getFontMap(boolean forceReload){
  if (ourFontCreationMethod == null) {
    return Collections.emptyMap();
  }
  final long timeStamp=System.currentTimeMillis();
  if (forceReload && timeStamp < ourTimeStamp + 1000) {
    forceReload=false;
  }
  ourTimeStamp=timeStamp;
  if (ourFileSet == null || forceReload) {
    final HashSet<File> fileSet=new HashSet<File>();
    final FilenameFilter filter=new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        if (name.startsWith(".")) {
          return false;
        }
        final String lcName=name.toLowerCase();
        return lcName.endsWith(".ttf") || lcName.endsWith(".otf");
      }
    }
;
    final File[] fileList=new File(Paths.FontsDirectoryOption().getValue()).listFiles(filter);
    if (fileList != null) {
      fileSet.addAll(Arrays.asList(fileList));
    }
    if (!fileSet.equals(ourFileSet)) {
      ourFileSet=fileSet;
      ourFontMap=new ZLTTFInfoDetector().collectFonts(fileSet);
    }
  }
  return ourFontMap;
}
 

Example 30

From project GraphWalker, under directory /src/main/java/org/graphwalker/io/.

Source file: GraphML.java

  17 
vote

/** 
 * Reads one single graph, or a folder containing several graphs to be merged into one graph.
 * @see org.graphwalker.io.AbstractModelHandler#load(java.lang.String)
 * @param fileOrfolder The gramphml file or folder.
 */
@Override public void load(String fileOrfolder){
  if (!"".equals(fileOrfolder)) {
    File file=Util.getFile(fileOrfolder);
    if (file.isFile()) {
      parsedGraphList.add(parseFile(fileOrfolder));
      setMerged(false);
    }
 else     if (file.isDirectory()) {
      FilenameFilter graphmlFilter=new FilenameFilter(){
        @Override public boolean accept(        File dir,        String name){
          return name.endsWith(".graphml");
        }
      }
;
      File[] allChildren=file.listFiles(graphmlFilter);
      for (      File anAllChildren : allChildren) {
        parsedGraphList.add(parseFile(anAllChildren.getAbsolutePath()));
        setMerged(false);
      }
    }
 else {
      throw new RuntimeException("'" + fileOrfolder + "' is not a file or a directory. Please specify a valid .graphml file or a directory containing .graphml files");
    }
  }
  mergeAllGraphs();
}
 

Example 31

From project gwt-mvp-contacts, under directory /com.toedter.gwt.demo.contacts/src/com/toedter/gwt/demo/contacts/server/.

Source file: VCardContactsRepository.java

  17 
vote

private File[] getContacts() throws Exception {
  String dir=getVCardsDir();
  File directory=new File(dir);
  System.out.println("VCardContactsRepository loading vcards from" + directory.getCanonicalPath());
  return directory.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.endsWith(".vcf");
    }
  }
);
}
 

Example 32

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

Source file: CheckpointUtils.java

  17 
vote

/** 
 * @return Instance of filename filter that will let through files endingin '.jdb' (i.e. bdb je log files).
 */
public static FilenameFilter getJeLogsFilter(){
  return new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name != null && name.toLowerCase().endsWith(".jdb");
    }
  }
;
}
 

Example 33

From project hibernate-metamodelgen, under directory /src/test/java/org/hibernate/jpamodelgen/test/util/.

Source file: CompilationTest.java

  17 
vote

protected List<File> getCompilationUnits(String baseDir,String packageName){
  List<File> javaFiles=new ArrayList<File>();
  String packageDirName=baseDir;
  if (packageName != null) {
    packageDirName=packageDirName + DIRECTORY_SEPARATOR + packageName.replace(".",DIRECTORY_SEPARATOR);
  }
  File packageDir=new File(packageDirName);
  FilenameFilter javaFileFilter=new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.endsWith(".java") && !name.endsWith("Test.java");
    }
  }
;
  final File[] files=packageDir.listFiles(javaFileFilter);
  if (files == null) {
    throw new RuntimeException("Cannot find package directory (is your base dir correct?): " + packageDirName);
  }
  javaFiles.addAll(Arrays.asList(files));
  return javaFiles;
}
 

Example 34

From project hibernate-tools, under directory /src/java/org/hibernate/tool/hbm2x/.

Source file: XMLPrettyPrinter.java

  17 
vote

/** 
 * @param outputdir
 * @throws IOException
 */
public static void prettyPrintDirectory(File outputdir,final String prefix,boolean silent) throws IOException {
  File[] files=outputdir.listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(prefix);
    }
  }
);
  Tidy tidy=getDefaultTidy();
  prettyPrintFiles(tidy,files,files,silent);
}
 

Example 35

From project iserve, under directory /iserve-parent/iserve-importer-sawsdl/src/test/java/uk/ac/open/kmi/iserve/importer/sawsdl/.

Source file: SawsdlImporterTest.java

  17 
vote

/** 
 * @throws IOException 
 * @throws ImporterException 
 */
private void importSawsdlTc() throws IOException, ImporterException {
  File dir=new File(TEST_COLLECTION_FOLDER);
  FilenameFilter filter=new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(".wsdl");
    }
  }
;
  File[] children=dir.listFiles(filter);
  if (children == null) {
  }
 else {
    for (int i=0; i < children.length; i++) {
      File file=children[i];
      String contents=IOUtil.readString(file);
      String serviceUri=importer.importService(file.getName(),contents,"http://test.com/test.html");
      System.out.println(serviceUri);
    }
  }
}
 

Example 36

From project Ivory_1, under directory /src/java/integration/ivory/integration/.

Source file: IntegrationUtils.java

  17 
vote

public static String getJar(String path,final String prefix){
  File[] arr=new File(path).listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.startsWith(prefix) && !name.contains("javadoc") && !name.contains("sources");
    }
  }
);
  assertTrue(arr.length == 1);
  return arr[0].getAbsolutePath();
}
 

Example 37

From project JaamSim, under directory /com/sandwell/JavaSimulation/.

Source file: Simulation.java

  17 
vote

/** 
 * Returns the first CHM file containing the given string in the file name, or null if not found
 */
public static File getCHMFile(String str){
  final FilenameFilter helpFilter=new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.matches(".+.[cC][hH][mM]");
    }
  }
;
  File[] chmFiles=null;
  String exe4j=System.getProperty("exe4j.moduleName");
  if (exe4j != null) {
    try {
      chmFiles=new File(exe4j).getParentFile().listFiles(helpFilter);
    }
 catch (    Exception e) {
    }
  }
  if (chmFiles == null) {
    URI res;
    try {
      res=Simulation.class.getProtectionDomain().getCodeSource().getLocation().toURI();
    }
 catch (    URISyntaxException e) {
      return null;
    }
    File temp=new File(res);
    if (!temp.isDirectory())     temp=temp.getParentFile();
    chmFiles=temp.listFiles(helpFilter);
  }
  if (chmFiles == null || chmFiles.length == 0)   return null;
  for (  File each : chmFiles) {
    if (each.exists() && each.getName().contains(str)) {
      return each;
    }
  }
  return null;
}
 

Example 38

From project jaffl, under directory /src/com/kenai/jaffl/.

Source file: Platform.java

  17 
vote

@Override public String locateLibrary(final String libName,List<String> libraryPath){
  FilenameFilter filter=new FilenameFilter(){
    Pattern p=Pattern.compile("lib" + libName + "\\.so\\.[0-9]+$");
    String exact="lib" + libName + ".so";
    public boolean accept(    File dir,    String name){
      return p.matcher(name).matches() || exact.equals(name);
    }
  }
;
  List<File> matches=new LinkedList<File>();
  for (  String path : libraryPath) {
    File[] files=new File(path).listFiles(filter);
    if (files != null && files.length > 0) {
      matches.addAll(Arrays.asList(files));
    }
  }
  int version=0;
  String bestMatch=null;
  for (  File file : matches) {
    String path=file.getAbsolutePath();
    if (bestMatch == null && path.endsWith(".so")) {
      bestMatch=path;
      version=0;
    }
 else {
      String num=path.substring(path.lastIndexOf(".so.") + 4);
      try {
        if (Integer.parseInt(num) >= version) {
          bestMatch=path;
        }
      }
 catch (      NumberFormatException e) {
      }
    }
  }
  return bestMatch != null ? bestMatch : mapLibraryName(libName);
}
 

Example 39

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

Source file: MaildirMailboxMapper.java

  17 
vote

/** 
 * @see org.apache.james.mailbox.store.mail.MailboxMapper#findMailboxWithPathLike(org.apache.james.mailbox.model.MailboxPath)
 */
@Override public List<Mailbox<Integer>> findMailboxWithPathLike(MailboxPath mailboxPath) throws MailboxException {
  final Pattern searchPattern=Pattern.compile("[" + MaildirStore.maildirDelimiter + "]"+ mailboxPath.getName().replace(".","\\.").replace(MaildirStore.WILDCARD,".*"));
  FilenameFilter filter=MaildirMessageName.createRegexFilter(searchPattern);
  File root=maildirStore.getMailboxRootForUser(mailboxPath.getUser());
  File[] folders=root.listFiles(filter);
  ArrayList<Mailbox<Integer>> mailboxList=new ArrayList<Mailbox<Integer>>();
  for (  File folder : folders)   if (folder.isDirectory()) {
    Mailbox<Integer> mailbox=maildirStore.loadMailbox(session,root,mailboxPath.getNamespace(),mailboxPath.getUser(),folder.getName());
    mailboxList.add(cacheMailbox(mailbox));
  }
  if (Pattern.matches(mailboxPath.getName().replace(MaildirStore.WILDCARD,".*"),MailboxConstants.INBOX)) {
    Mailbox<Integer> mailbox=maildirStore.loadMailbox(session,root,mailboxPath.getNamespace(),mailboxPath.getUser(),"");
    mailboxList.add(0,cacheMailbox(mailbox));
  }
  return mailboxList;
}
 

Example 40

From project java-gae-verifier, under directory /src/org/mozilla/javascript/.

Source file: RhinoException.java

  17 
vote

/** 
 * Get a string representing the script stack of this exception. If optimization is enabled, this corresponds to all java stack elements with a source name ending with ".js".
 * @return a script stack dump
 * @since 1.6R6
 */
public String getScriptStackTrace(){
  return getScriptStackTrace(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(".js");
    }
  }
);
}
 

Example 41

From project javaee-tutorial, under directory /jaxrs/client/src/test/java/org/jboss/ee/tutorial/jaxrs/client/.

Source file: JaxrsClientTestCase.java

  17 
vote

@Deployment(testable=false) public static Archive<?> deploy(){
  File serverTargetDir=new File("../server/target");
  String[] list=serverTargetDir.list(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(".war");
    }
  }
);
  File warFile=new File(serverTargetDir + "/" + list[0]);
  JavaArchive archive=ShrinkWrap.createFromZipFile(JavaArchive.class,warFile);
  return archive;
}
 

Example 42

From project jDcHub, under directory /jdchub-core/src/main/java/ru/sincore/modules/.

Source file: ModulesManager.java

  17 
vote

private File[] findModules(){
  File modulesDirectory=new File(this.modulesDirectory);
  File[] moduleJars=modulesDirectory.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return (name.endsWith(".jar"));
    }
  }
);
  if (moduleJars == null) {
    return null;
  }
  return moduleJars;
}
 

Example 43

From project jentrata-msh, under directory /Commons/src/main/java/hk/hku/cecid/piazza/commons/spa/.

Source file: Plugin.java

  17 
vote

private void addNestedJars(File dir,ArrayList<URL> urls) throws MalformedURLException {
  File[] files=dir.listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String filename){
      return filename.endsWith(".jar");
    }
  }
);
  for (  File f : files) {
    urls.add(f.toURI().toURL());
  }
}
 

Example 44

From project JGlobus, under directory /ssl-proxies/src/main/java/org/globus/gsi/stores/.

Source file: ResourceSecurityWrapperStore.java

  17 
vote

private Set<V> addCredentials(File directory,Map<String,T> newWrapperMap) throws ResourceStoreException {
  FilenameFilter filter=getDefaultFilenameFilter();
  String[] children=directory.list(filter);
  Set<V> roots=new HashSet<V>();
  if (children == null) {
    return roots;
  }
  try {
    for (    String child : children) {
      File childFile=new File(directory,child);
      if (childFile.isDirectory()) {
        roots.addAll(addCredentials(childFile,newWrapperMap));
      }
 else {
        GlobusResource resource=new GlobusResource(childFile.getAbsolutePath());
        String resourceUri=resource.getURI().toASCIIString();
        T fbo=this.wrapperMap.get(resourceUri);
        if (fbo == null) {
          fbo=create(new GlobusResource(childFile.getAbsolutePath()));
        }
        V target=fbo.create(resource);
        newWrapperMap.put(resourceUri,fbo);
        roots.add(target);
      }
    }
    return roots;
  }
 catch (  IOException e) {
    throw new ResourceStoreException(e);
  }
}
 

Example 45

From project jsfunit, under directory /jboss-jsfunit-analysis/src/main/java/org/jboss/jsfunit/analysis/util/.

Source file: FileUtils.java

  17 
vote

/** 
 * Find all files in the passed in directory.
 * @param folder File object of a folder
 * @param allowedExtensions list off allowed file extensions
 * @return a list of file-paths
 */
public static List<String> findFiles(File folder,List<String> allowedExtensions){
  if (folder == null) {
    throw new IllegalArgumentException("Folder must not be null");
  }
  String folderPath;
  try {
    folderPath=folder.getCanonicalPath() + File.separator;
  }
 catch (  IOException e) {
    folderPath="---exception: " + e.getLocalizedMessage() + File.separator;
  }
  List<String> foundFiles=new ArrayList<String>();
  FilenameFilter filter=new FileUtils.FileExtensionFilter(allowedExtensions);
  String[] files=folder.list(filter);
  for (int i=0; i < files.length; i++) {
    foundFiles.add(folderPath + files[i]);
  }
  return foundFiles;
}
 

Example 46

From project juzu, under directory /core/src/main/java/juzu/impl/fs/spi/disk/.

Source file: DiskFileSystem.java

  17 
vote

public DiskFileSystem(File root){
  this(root,new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return true;
    }
  }
);
}
 

Example 47

From project Kairos, under directory /src/java/org/apache/nutch/kairos/crf/.

Source file: DictionarySingleton.java

  17 
vote

public static void main(String[] args){
  DictionarySingleton dictionary=DictionarySingleton.getInstance();
  FilenameFilter txtFilter=new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(".txt");
    }
  }
;
  File dictionaryDirectory=new File("/Users/myd/Downloads/dictionaries/");
  File[] dictionaryFiles=dictionaryDirectory.listFiles(txtFilter);
  for (  File currentDictionaryFile : dictionaryFiles) {
    List<String> dictionaryEntries=Utils.readFile(currentDictionaryFile);
    HashSet<String> dictionaryValues=new HashSet<String>();
    for (    String currentDictionaryEntry : dictionaryEntries) {
      currentDictionaryEntry=currentDictionaryEntry.trim();
      if (currentDictionaryEntry.startsWith("#") || StringUtil.isEmpty(currentDictionaryEntry)) {
      }
 else {
        if (currentDictionaryEntry.indexOf("\t") != -1) {
          String[] splits=currentDictionaryEntry.split("\t");
          String value=splits[0];
          dictionaryValues.add(value);
        }
 else {
          dictionaryValues.add(currentDictionaryEntry);
        }
      }
    }
    dictionary.put(currentDictionaryFile.getName(),dictionaryValues);
  }
  for (  File currentDictionaryFile : dictionaryFiles) {
    HashSet<String> values=dictionary.get(currentDictionaryFile.getName());
    List<String> lines=new LinkedList<String>();
    for (    String string : values) {
      lines.add(string);
    }
    String path=currentDictionaryFile.getAbsolutePath();
    Utils.writeLinesToFile(new File(path + "_NEW.txt"),lines,Utils.NEWLINE,true);
  }
}
 

Example 48

From project knime-scripting, under directory /groovy4knime/src/de/mpicbg/tds/knime/scripting/groovy/.

Source file: GroovyScriptNodeModel.java

  17 
vote

private ClassLoader createClassLoader() throws MalformedURLException {
  IPreferenceStore prefStore=GroovyScriptingBundleActivator.getDefault().getPreferenceStore();
  String classpathAddons=prefStore.getString(GroovyScriptingPreferenceInitializer.GROOVY_CLASSPATH_ADDONS);
  classpathAddons.replace("\n",";");
  List<URL> urls=new ArrayList<URL>();
  for (  String classPathEntry : classpathAddons.split(";")) {
    classPathEntry=classPathEntry.trim();
    if (classPathEntry.trim().startsWith("#"))     continue;
    classPathEntry=classPathEntry.replace("{KNIME.HOME}",System.getProperty("osgi.syspath"));
    try {
      if (classPathEntry.endsWith("*")) {
        FilenameFilter jarFilter=new FilenameFilter(){
          public boolean accept(          File file,          String s){
            return s.endsWith(".jar");
          }
        }
;
        for (        File file : new File(classPathEntry).getParentFile().listFiles(jarFilter)) {
          urls.add(file.toURL());
        }
      }
 else {
        File file=new File(classPathEntry);
        if (file.exists()) {
          urls.add(file.toURL());
        }
      }
    }
 catch (    Throwable t) {
      logger.error("The url '" + classPathEntry + "' does not exist. Please correct the entry in Preferences > KNIME > Groovy Scripting");
    }
  }
  return new URLClassLoader(urls.toArray(new URL[0]),this.getClass().getClassLoader());
}
 

Example 49

From project koshinuke.java, under directory /test/java/org/koshinuke/test/.

Source file: KoshinukeTest.java

  17 
vote

public static void deleteDirs() throws Exception {
  File bin=new File("bin");
  for (  File test : bin.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.startsWith("test");
    }
  }
)) {
    FileUtils.delete(test,FileUtils.RECURSIVE | FileUtils.SKIP_MISSING);
  }
}
 

Example 50

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

Source file: GeneradorFicherosSeneca.java

  17 
vote

public File[] getFicherosExistentes(){
  return getCarpetaSalida().listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.endsWith(".xml");
    }
  }
);
}
 

Example 51

From project maven3-support, under directory /maven3-plugin/src/main/java/org/hudsonci/maven/plugin/documents/internal/.

Source file: DocumentStoreImpl.java

  17 
vote

public Collection<DocumentDTO> loadAll() throws IOException {
  FilenameFilter filter=new FilenameFilter(){
    public boolean accept(    final File dir,    final String name){
      return name.endsWith(FILE_SUFFIX);
    }
  }
;
  List<DocumentDTO> documents=new ArrayList<DocumentDTO>();
  Set<String> ids=new HashSet<String>();
  if (rootDir.exists()) {
    log.debug("Loading documents from directory: {}",rootDir);
    for (    File file : rootDir.listFiles(filter)) {
      DocumentDTO document=load(file);
      String id=document.getId();
      if (ids.contains(id)) {
        log.warn("Duplicate document ID detected: {}",id);
      }
      ids.add(id);
      documents.add(document);
    }
  }
  return documents;
}
 

Example 52

From project Aardvark, under directory /aardvark/src/main/test/gw/vark/it/.

Source file: ITUtil.java

  16 
vote

public static File findFile(File dir,final String pattern) throws FileNotFoundException {
  if (!dir.exists()) {
    throw new IllegalArgumentException(dir + " does not exist");
  }
  if (!dir.isDirectory()) {
    throw new IllegalArgumentException(dir + " is not a directory");
  }
  File[] found=dir.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.matches(pattern);
    }
  }
);
  if (found.length == 0) {
    throw new FileNotFoundException("file matching pattern \"" + pattern + "\" not found in directory "+ dir);
  }
  if (found.length > 1) {
    throw new FileNotFoundException("multiple files found matching pattern \"" + pattern + "\" in directory "+ dir);
  }
  return found[0];
}
 

Example 53

From project activejdbc, under directory /activejdbc-instrumentation/src/main/java/org/javalite/instrumentation/.

Source file: InstrumentationModelFinder.java

  16 
vote

/** 
 * This will scan directory for class files, non-recurive.
 * @param directory directory to scan.
 * @throws IOException , NotFoundException
 */
private void findFiles(File directory) throws IOException, ClassNotFoundException {
  File files[]=directory.listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(".class");
    }
  }
);
  if (files != null) {
    for (    File file : files) {
      int current=currentDirectoryPath.length();
      String fileName=file.getCanonicalPath().substring(++current);
      String className=fileName.replace(File.separatorChar,'.').substring(0,fileName.length() - 6);
      classFound(className);
    }
  }
}
 

Example 54

From project AdServing, under directory /modules/server/adserver/src/main/java/net/mad/ads/server/utils/listener/.

Source file: StartupPlugIn.java

  16 
vote

private void initTemplates(String path) throws IOException {
  File tdir=new File(path);
  File[] templates=tdir.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      if (name.endsWith(".ftl")) {
        return true;
      }
      return false;
    }
  }
);
  TemplateManager tempMan=new FMTemplateManager();
  tempMan.init(path);
  for (  File template : templates) {
    String tname=Strings.removeExtension(template.getName()).toLowerCase();
    tempMan.registerTemplate(tname,template.getName());
  }
  RuntimeContext.setTemplateManager(tempMan);
}
 

Example 55

From project aether-core, under directory /aether-connector-asynchttpclient/src/main/java/org/eclipse/aether/connector/async/.

Source file: AsyncRepositoryConnector.java

  16 
vote

/** 
 * Create a  {@link FileLockCompanion} containing a reference to a temporary {@link File} used when downloadinga remote file. If a local and incomplete version of a file is available, use that file and resume bytes downloading. To prevent multiple process trying to resume the same file, a  {@link FileLock} companion to the tmeporary file iscreated and used to prevent concurrency issue.
 * @param path           The downloaded path
 * @param allowResumable Allow resumable download, or not.
 * @return
 */
private FileLockCompanion createOrGetTmpFile(String path,boolean allowResumable){
  if (!disableResumeSupport && allowResumable) {
    File f=new File(path);
    File parentFile=f.getParentFile();
    if (parentFile.isDirectory()) {
      for (      File tmpFile : parentFile.listFiles(new FilenameFilter(){
        public boolean accept(        File dir,        String name){
          if (name.indexOf(".") > 0 && name.lastIndexOf(".") == name.indexOf(".ahc")) {
            return true;
          }
          return false;
        }
      }
)) {
        if (tmpFile.length() > 0) {
          String realPath=tmpFile.getPath().substring(0,tmpFile.getPath().lastIndexOf("."));
          FileLockCompanion fileLockCompanion=null;
          if (realPath.equals(path)) {
            File newFile=tmpFile;
synchronized (activeDownloadFiles) {
              fileLockCompanion=lockFile(tmpFile);
              logger.debug(String.format("Found an incomplete download for file %s.",path));
              if (fileLockCompanion.getLock() == null) {
                newFile=getTmpFile(path);
                fileLockCompanion=lockFile(newFile);
              }
              return fileLockCompanion;
            }
          }
        }
      }
    }
  }
  return new FileLockCompanion(getTmpFile(path),null);
}
 

Example 56

From project airlift, under directory /log/src/main/java/io/airlift/log/.

Source file: Logging.java

  16 
vote

private void recoverTempFiles(String logPath){
  File logPathFile=new File(logPath).getParentFile();
  File[] tempFiles=logPathFile.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.endsWith(TEMP_FILE_EXTENSION);
    }
  }
);
  if (tempFiles != null) {
    for (    File tempFile : tempFiles) {
      String newName=tempFile.getName().substring(0,tempFile.getName().length() - TEMP_FILE_EXTENSION.length());
      File newFile=new File(tempFile.getParent(),newName + LOG_FILE_EXTENSION);
      if (tempFile.renameTo(newFile)) {
        log.info("Recovered temp file: %s",tempFile);
      }
 else {
        log.warn("Could not rename temp file [%s] to [%s]",tempFile,newFile);
      }
    }
  }
}
 

Example 57

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/preference/activity/.

Source file: PreferencesRestoreBackupActivity.java

  16 
vote

private void setupFileSpinner(){
  String storage_state=Environment.getExternalStorageState();
  if (!Environment.MEDIA_MOUNTED.equals(storage_state)) {
    String message=getString(R.string.warning_media_not_mounted,storage_state);
    Log.e(cTag,message);
    AlertUtils.showWarning(this,message);
    setState(State.COMPLETE);
    return;
  }
  File dir=Environment.getExternalStorageDirectory();
  String[] files=dir.list(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String filename){
      return !filename.startsWith(".");
    }
  }
);
  if (files == null || files.length == 0) {
    String message=getString(R.string.warning_no_files,storage_state);
    Log.e(cTag,message);
    AlertUtils.showWarning(this,message);
    setState(State.COMPLETE);
    return;
  }
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,files);
  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  mFileSpinner.setAdapter(adapter);
  int selectedIndex=0;
  long lastModified=Long.MIN_VALUE;
  for (int i=0; i < files.length; i++) {
    String filename=files[i];
    File f=new File(dir,filename);
    if (f.getName().endsWith(".bak") && f.lastModified() > lastModified) {
      selectedIndex=i;
      lastModified=f.lastModified();
    }
  }
  mFileSpinner.setSelection(selectedIndex);
}
 

Example 58

From project androidpn, under directory /androidpn-server-src/starter/src/main/java/org/androidpn/server/starter/.

Source file: ServerClassLoader.java

  16 
vote

/** 
 * Constructs the classloader.
 * @param parent the parent class loader (or null for none)
 * @param confDir the directory to load configration files from
 * @param libDir the directory to load jar files from
 * @throws java.net.MalformedURLException if the libDir path is not valid
 */
public ServerClassLoader(ClassLoader parent,File confDir,File libDir) throws MalformedURLException {
  super(new URL[]{confDir.toURI().toURL(),libDir.toURI().toURL()},parent);
  File[] jars=libDir.listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      boolean accept=false;
      String smallName=name.toLowerCase();
      if (smallName.endsWith(".jar")) {
        accept=true;
      }
 else       if (smallName.endsWith(".zip")) {
        accept=true;
      }
      return accept;
    }
  }
);
  if (jars == null) {
    return;
  }
  for (int i=0; i < jars.length; i++) {
    if (jars[i].isFile()) {
      addURL(jars[i].toURI().toURL());
    }
  }
}
 

Example 59

From project any23, under directory /api/src/main/java/org/apache/any23/plugin/.

Source file: Any23PluginManager.java

  16 
vote

/** 
 * Loads all the JARs detected in a given directory.
 * @param jarDir directory containing the JARs to be loaded.
 * @return <code>true</code> if all JARs in dir are loaded.
 */
public synchronized boolean loadJARDir(File jarDir){
  if (jarDir == null)   throw new NullPointerException("JAR dir must be not null.");
  if (!jarDir.exists())   throw new IllegalArgumentException("Given directory doesn't exist:" + jarDir.getAbsolutePath());
  if (!jarDir.isDirectory())   throw new IllegalArgumentException("given file exists and it is not a directory: " + jarDir.getAbsolutePath());
  boolean loaded=true;
  for (  File jarFile : jarDir.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.endsWith(".jar");
    }
  }
)) {
    loaded&=loadJAR(jarFile);
  }
  return loaded;
}
 

Example 60

From project Blitz, under directory /src/com/laxser/blitz/web/instruction/.

Source file: ViewInstruction.java

  16 
vote

/** 
 * ??????????????????????????????????????????????
 * @param tempHome
 * @param subDirPath
 * @return
 */
private File searchDirectory(File tempHome,String subDirPath){
  String[] subDirs=StringUtils.split(subDirPath,"/");
  for (  final String subDir : subDirs) {
    File file=new File(tempHome,subDir);
    if (!file.exists()) {
      String[] candidates=tempHome.list(new FilenameFilter(){
        @Override public boolean accept(        File dir,        String name){
          if (name.equalsIgnoreCase(subDir)) {
            return true;
          }
          return false;
        }
      }
);
      if (candidates.length == 0) {
        tempHome=null;
        break;
      }
 else {
        tempHome=new File(tempHome,candidates[0]);
      }
    }
 else {
      tempHome=file;
    }
  }
  return tempHome;
}
 

Example 61

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

Source file: NameFinderFactory.java

  16 
vote

/** 
 * Load the name finder models. Currently any file in the model directory that starts with (lang)-ner
 * @param language
 * @param modelDirectory can be null to use the value of the system property model.dir
 * @return 
 */
protected File[] findNameFinderModels(String language,String modelDirectory){
  final String modelPrefix=language + "-ner";
  log.info("Loading name finder models from {} using prefix {} ",new Object[]{modelDirectory,modelPrefix});
  File[] models=new File(modelDirectory).listFiles(new FilenameFilter(){
    public boolean accept(    File file,    String name){
      if (name.startsWith(modelPrefix)) {
        return true;
      }
      return false;
    }
  }
);
  if (models == null || models.length < 1) {
    throw new RuntimeException("Configuration Error: No models in " + modelDirectory);
  }
  return models;
}
 

Example 62

From project build-info, under directory /build-info-extractor-maven3/src/main/java/org/jfrog/build/extractor/maven/.

Source file: BuildInfoRecorder.java

  16 
vote

private List<File> getSurefireResultsFile(MavenProject project){
  List<File> surefireReports=Lists.newArrayList();
  File surefireDirectory=new File(new File(project.getFile().getParentFile(),"target"),"surefire-reports");
  String[] xmls;
  try {
    xmls=surefireDirectory.list(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.endsWith("xml");
      }
    }
);
  }
 catch (  Exception e) {
    logger.error("Error occurred: " + e.getMessage() + " while retrieving surefire descriptors at: "+ surefireDirectory.getAbsolutePath(),e);
    return Lists.newArrayList();
  }
  if (xmls != null) {
    for (    String xml : xmls) {
      surefireReports.add(new File(surefireDirectory,xml));
    }
  }
  return surefireReports;
}
 

Example 63

From project CCR-Validator, under directory /src/main/java/org/openhealthdata/validator/.

Source file: DroolsUtil.java

  16 
vote

public static FilenameFilter getFilter(ResourceType rt){
  if (rt == ResourceType.DRL) {
    return new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.endsWith(".drl");
      }
    }
;
  }
  if (rt == ResourceType.DRF) {
    return new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.endsWith(".drf");
      }
    }
;
  }
  return new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(".drl");
    }
  }
;
}
 

Example 64

From project CHMI, under directory /src/org/kaldax/app/chmi/img/.

Source file: ImagesHandlerImpl.java

  16 
vote

public void ClearCache(){
synchronized (data_sync) {
    File storageRoot=Environment.getExternalStorageDirectory();
    File appStorageRoot=new File(storageRoot,IMG_DIR);
    File[] files=appStorageRoot.listFiles(new FilenameFilter(){
      public boolean accept(      File arg0,      String arg1){
        return arg1.endsWith(IMG_SUFFIX);
      }
    }
);
    for (int iCnt=0; iCnt < files.length; iCnt++) {
      if (!isFileInCacheList(files[iCnt].getName())) {
{
          Logger.global.log(Level.WARNING,"Deleting " + files[iCnt].getName());
          files[iCnt].delete();
          new File(files[iCnt].getAbsolutePath() + ".val").delete();
        }
      }
    }
  }
}
 

Example 65

From project chukwa, under directory /src/main/java/org/apache/hadoop/chukwa/database/.

Source file: DatabaseConfig.java

  16 
vote

public DatabaseConfig(){
  String dataConfig=System.getenv("CHUKWA_CONF_DIR");
  if (dataConfig == null) {
    dataConfig=MDL_XML;
  }
 else {
    dataConfig+=File.separator + MDL_XML;
  }
  Path fileResource=new Path(dataConfig);
  config=new Configuration();
  config.addResource(fileResource);
  if (System.getenv("CHUKWA_CONF_DIR") != null) {
    File confDir=new File(System.getenv("CHUKWA_CONF_DIR"));
    File[] confFiles=confDir.listFiles(new FilenameFilter(){
      @Override public boolean accept(      File dir,      String name){
        return name.endsWith(MDL_XML) && !name.equals(MDL_XML);
      }
    }
);
    if (confFiles != null) {
      for (      File confFile : confFiles)       config.addResource(new Path(confFile.getAbsolutePath()));
    }
  }
}
 

Example 66

From project cipango, under directory /cipango-console/src/main/java/org/cipango/console/.

Source file: Deployer.java

  16 
vote

private boolean deleteAll(File root){
  boolean success=true;
  if (root.exists()) {
    if (!root.isDirectory()) {
      success=root.delete();
    }
 else {
      File[] files=root.listFiles(new FilenameFilter(){
        public boolean accept(        File dir,        String name){
          if (name.equals(".") || name.equals("..")) {
            return false;
          }
          return true;
        }
      }
);
      for (int i=0; i < files.length; i++) {
        success=deleteAll(files[i]) && success;
      }
      success=root.delete() && success;
    }
  }
  return success;
}
 

Example 67

From project cloudify, under directory /dsl/src/main/java/org/cloudifysource/dsl/internal/.

Source file: DSLReader.java

  16 
vote

/** 
 * .
 * @param fileNameSuffix .
 * @param dir .
 * @return .
 */
public static File findDefaultDSLFile(final String fileNameSuffix,final File dir){
  final File[] files=dir.listFiles(new FilenameFilter(){
    @Override public boolean accept(    final File dir,    final String name){
      return name.endsWith(fileNameSuffix);
    }
  }
);
  if (files.length > 1) {
    throw new IllegalArgumentException("Found multiple configuration files: " + Arrays.toString(files) + ". "+ "Only one may be supplied in the folder.");
  }
  if (files.length == 0) {
    throw new IllegalArgumentException("Cannot find configuration file in " + dir.getAbsolutePath() + "/*"+ fileNameSuffix);
  }
  return files[0];
}
 

Example 68

From project core_4, under directory /impl/src/test/integration/org/richfaces/integration/.

Source file: CoreDeployment.java

  16 
vote

/** 
 * Resolves maven dependencies, either by  {@link MavenDependencyResolver} or from file cache
 */
private void addMavenDependencies(WebArchive finalArchive){
  Set<File> jarFiles=Sets.newHashSet();
  for (  String dependency : mavenDependencies) {
    File cacheDir=new File("target/shrinkwrap-resolver-cache/" + dependency);
    if (!cacheDir.exists()) {
      resolveMavenDependency(dependency,cacheDir);
    }
    File[] listFiles=cacheDir.listFiles(new FilenameFilter(){
      @Override public boolean accept(      File dir,      String name){
        return name.endsWith(".jar");
      }
    }
);
    jarFiles.addAll(Arrays.asList(listFiles));
  }
  File[] files=jarFiles.toArray(new File[jarFiles.size()]);
  finalArchive.addAsLibraries(files);
}
 

Example 69

From project daap, under directory /src/main/java/org/ardverk/daap/tools/.

Source file: ChunkUtil.java

  16 
vote

public static Chunk[] getChunks(File dir){
  String[] files=dir.list(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(".java");
    }
  }
);
  Chunk[] chunks=new Chunk[files.length];
  try {
    for (int i=0; i < files.length; i++) {
      String clazzName=CHUNK_IMPL_PACKAGE + "." + files[i].substring(0,files[i].length() - ".java".length());
      Class clazz=Class.forName(clazzName);
      chunks[i]=(AbstractChunk)clazz.newInstance();
    }
  }
 catch (  ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
catch (  InstantiationException e) {
    throw new RuntimeException(e);
  }
catch (  IllegalAccessException e) {
    throw new RuntimeException(e);
  }
  return chunks;
}
 

Example 70

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

Source file: Files.java

  16 
vote

/** 
 * Copy database files which include dm_master.db, dm.db and dm_<i>bookid<i>.db
 * @param sourceFolder source folder
 * @param targetFolder target folder
 * @param date Copy date. If date is not null, it will make another copy named with '.yyyyMMdd_HHmmss' as suffix.  It is also used to identify copy from SD to DB when date is null 
 * @return Number of files copied.
 * @throws IOException
 */
public static int copyDatabases(File sourceFolder,File targetFolder,Date date) throws IOException {
  int count=0;
  String state=Environment.getExternalStorageState();
  if (Environment.MEDIA_MOUNTED.equals(state) && sourceFolder.exists() && targetFolder.exists()) {
    String[] filenames=sourceFolder.list(new FilenameFilter(){
      @Override public boolean accept(      File dir,      String filename){
        if (filename.startsWith("dm") && filename.endsWith(".db")) {
          return true;
        }
        return false;
      }
    }
);
    String bakDate=date == null ? null : backupDateFmt.format(date) + ".bak";
    if (filenames != null && filenames.length != 0) {
      List<String> dbs=Arrays.asList(filenames);
      if (dbs.contains("dm_master.db") && dbs.contains("dm.db")) {
        for (        String db : dbs) {
          Files.copyFileTo(new File(sourceFolder,db),new File(targetFolder,db));
          count++;
          if (bakDate != null) {
            Files.copyFileTo(new File(sourceFolder,db),new File(targetFolder,db + "." + bakDate));
          }
        }
      }
    }
  }
  return count;
}
 

Example 71

From project datafu, under directory /test/pig/datafu/test/pig/.

Source file: PigTests.java

  16 
vote

protected String getJarPath(){
  System.out.println("Getting jar path");
  String jarDir=null;
  if (System.getProperty("datafu.jar.dir") != null) {
    jarDir=System.getProperty("datafu.jar.dir");
  }
 else {
    jarDir=new File(System.getProperty("user.dir"),"dist").getAbsolutePath();
  }
  File userDir=new File(jarDir);
  String[] files=userDir.list(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.endsWith(".jar") && !name.contains("sources") && !name.contains("javadoc");
    }
  }
);
  if (files == null || files.length == 0) {
    throw new RuntimeException("Could not find JAR file");
  }
 else   if (files.length > 1) {
    throw new RuntimeException("Found more JAR files than expected");
  }
  return userDir.getAbsolutePath() + "/" + files[0];
}
 

Example 72

From project db2triples, under directory /src/test/java/.

Source file: MainIT.java

  16 
vote

@Parameters public static Collection<Object[]> getTestsFiles() throws Exception {
  Collection<Object[]> parameters=new Vector<Object[]>();
  File[] w3cDirs=w3cDefinitionSearchPath.listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.startsWith(w3cDirPrefix);
    }
  }
);
  int i=0;
  for (  File w3cDir : w3cDirs) {
    File[] files=w3cDir.listFiles();
    for (    File f : files) {
      if (f.isFile()) {
        continue;
      }
      final String file_path=f.getAbsolutePath();
      parameters.add(new Object[]{NormTested.DirectMapping,file_path,null});
      log.info("[W3CTester:test] Create parameter " + (i++) + " : {DirectMapping ; "+ file_path+ "}");
      for (      String suffix : r2rmlSuffixes) {
        final String test_filepath=file_path + "/r2rml" + suffix+ ".ttl";
        if ((new File(test_filepath)).exists()) {
          parameters.add(new Object[]{NormTested.R2RML,file_path,suffix});
          log.info("[W3CTester:test] Create parameter " + (i++) + " : {R2RML ; "+ file_path+ " ; "+ suffix+ "}");
        }
      }
    }
  }
  return parameters;
}
 

Example 73

From project droid-comic-viewer, under directory /src/net/robotmedia/acv/comic/.

Source file: FolderComic.java

  16 
vote

protected FolderComic(String path){
  super(path);
  File folder=new File(path);
  if (folder.isDirectory()) {
    String[] files=folder.list(new FilenameFilter(){
      public boolean accept(      File dir,      String filename){
        String ext=FileUtils.getFileExtension(filename);
        return FileUtils.isImage(ext);
      }
    }
);
    TreeMap<String,String> images=new TreeMap<String,String>();
    for (int i=0; i < files.length; i++) {
      final File current=new File(folder,files[i]);
      String currentPath=current.getPath();
      String pathWithLeadinZeroes=this.addLeadingZeroes(currentPath);
      images.put(pathWithLeadinZeroes,currentPath);
    }
    ArrayList<String> ordered=new ArrayList<String>(images.keySet());
    orderedScreens=new ArrayList<String>(ordered.size());
    for (int i=0; i < ordered.size(); i++) {
      orderedScreens.add(images.get(ordered.get(i)));
    }
  }
 else {
    error();
  }
}
 

Example 74

From project droid-fu, under directory /src/main/java/com/github/droidfu/cachefu/.

Source file: CacheHelper.java

  16 
vote

private static void removeExpiredCache(final AbstractCache<String,?> cache,final String urlPrefix){
  final File cacheDir=new File(cache.getDiskCacheDirectory());
  if (!cacheDir.exists()) {
    return;
  }
  File[] list=cacheDir.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String filename){
      return dir.equals(cacheDir) && filename.startsWith(cache.getFileNameForKey(urlPrefix));
    }
  }
);
  if (list == null || list.length == 0) {
    return;
  }
  for (  File file : list) {
    file.delete();
  }
}
 

Example 75

From project droidtv, under directory /src/com/chrulri/droidtv/utils/.

Source file: ProcessUtils.java

  16 
vote

public static void killBinary(Context ctx,int rawId) throws IOException {
  File exe=getBinaryExecutableFile(ctx,rawId);
  String exePath=exe.getCanonicalPath();
  File[] procs=new File("/proc").listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String filename){
      try {
        Integer.parseInt(filename);
        return true;
      }
 catch (      NumberFormatException e) {
        return false;
      }
    }
  }
);
  for (  File proc : procs) {
    File pexe=new File(proc,"exe");
    if (pexe.canRead()) {
      if (exePath.equals(pexe.getCanonicalPath())) {
        int pid=Integer.parseInt(proc.getName());
        terminate(pid);
      }
    }
  }
}
 

Example 76

From project eclipse-integration-gradle, under directory /org.springsource.ide.eclipse.gradle.core/src/org/springsource/ide/eclipse/gradle/core/preferences/.

Source file: GradlePreferences.java

  16 
vote

/** 
 * @return URI of a gradle distribution that is packaged up with GradleCore plugin.
 * @throws IOException if there is some problem getting the embedded distribution.
 */
public static URI getBuiltinDistribution() throws IOException {
  if (builtInDistribution == null) {
    debug(">>>> Searching for embedded Gradle install");
    Bundle coreBundle=Platform.getBundle(GradleCore.PLUGIN_ID);
    File coreBundleFile=FileLocator.getBundleFile(coreBundle);
    Assert.isNotNull(coreBundleFile);
    Assert.isLegal(coreBundleFile.isDirectory(),"The bundle " + coreBundle.getSymbolicName() + " must be unpacked to allow using the embedded gradle distribution");
    File libDir=new File(coreBundleFile,"lib");
    File[] candidates=libDir.listFiles(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.endsWith(".zip");
      }
    }
);
    if (GlobalSettings.DEBUG) {
      for (      File file : candidates) {
        debug("found: " + file);
      }
    }
    Assert.isTrue(candidates.length <= 1,"At most one embedded distribution should be found!");
    if (candidates.length == 1) {
      builtInDistribution=candidates[0].toURI();
      debug("Found embedded install: " + builtInDistribution);
    }
 else {
      debug("No embedded install found");
    }
    debug("<<<< Searching for embedded Gradle install");
  }
  return builtInDistribution;
}
 

Example 77

From project eik, under directory /plugins/info.evanchik.eclipse.karaf.ui/src/main/java/info/evanchik/eclipse/karaf/ui/project/impl/.

Source file: ConfigurationFileBuildUnit.java

  16 
vote

/** 
 * @param kind
 * @param args
 * @param monitor
 */
@Override public void build(final int kind,@SuppressWarnings("rawtypes") final Map args,final IProgressMonitor monitor) throws CoreException {
  final File configurationDirectory=getKarafPlatformModel().getConfigurationDirectory().toFile();
  final File configFiles[]=configurationDirectory.listFiles(new FilenameFilter(){
    @Override public boolean accept(    final File dir,    final String name){
      return name.endsWith(".cfg");
    }
  }
);
  final IFolder runtimeFolder=getKarafProject().getFolder("runtime");
  if (!runtimeFolder.exists()) {
    runtimeFolder.create(true,true,monitor);
  }
  final Properties configProperties=getKarafProject().getRuntimeProperties();
  for (  final File f : configFiles) {
    if (f.isDirectory()) {
      continue;
    }
    try {
      final FileInputStream in=new FileInputStream(f);
    }
 catch (    final FileNotFoundException e) {
    }
  }
}
 

Example 78

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

Source file: BackupService.java

  16 
vote

private static boolean bumpLogFile(String targetDirectory,long toTimestamp){
  File dbDirectory=new File(targetDirectory);
  File[] candidates=dbDirectory.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.equals(StringLogger.DEFAULT_NAME);
    }
  }
);
  File previous=null;
  if (candidates.length != 1) {
    return false;
  }
 else {
    previous=candidates[0];
  }
  File to=new File(previous.getParentFile(),StringLogger.DEFAULT_NAME + "." + toTimestamp);
  return previous.renameTo(to);
}
 

Example 79

From project erjang, under directory /src/main/java/erjang/.

Source file: RuntimeInfo.java

  16 
vote

public static String guess_erts_version(String erl_rootdir){
  String erts_version=guess_version(ERLANG_RELEASESTARTFILE_REGEX,1,erl_rootdir,ERLANG_RELEASESTARTFILE);
  if (isNullOrEmpty(erts_version)) {
    erts_version=guess_version(ERLANG_RELEASEFILE_REGEX,2,erl_rootdir,ERLANG_RELEASEFILE);
  }
  if (isNullOrEmpty(erts_version)) {
    File erlangRoot=new File(erl_rootdir);
    if (erlangRoot.isDirectory()) {
      File libDir=new File(erlangRoot,"lib");
      String[] ertsDirs=libDir.list(new FilenameFilter(){
        @Override public boolean accept(        File dir,        String name){
          return name.startsWith("erts-");
        }
      }
);
      if (ertsDirs != null) {
        for (int d=0; d < ertsDirs.length; d++) {
          String dir=ertsDirs[d];
          erts_version=dir;
        }
      }
    }
  }
  return erts_version;
}
 

Example 80

From project exo-training, under directory /gxt-showcase/src/main/java/com/sencha/gxt/examples/resources/server/.

Source file: ExampleServiceImpl.java

  16 
vote

private void loadPhotos(){
  photos=new ArrayList<Photo>();
  String url=getThreadLocalRequest().getSession().getServletContext().getRealPath("/examples/images/photos");
  File folder=new File(url);
  File[] pics=folder.listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return !name.startsWith(".");
    }
  }
);
  Arrays.sort(pics,new Comparator<File>(){
    public int compare(    File o1,    File o2){
      return o1.getName().compareTo(o2.getName());
    }
  }
);
  for (  File pic : pics) {
    Photo photo=new Photo();
    photo.setName(pic.getName());
    photo.setDate(new Date(pic.lastModified()));
    photo.setSize(pic.length());
    photo.setPath("examples/images/photos/" + pic.getName());
    photos.add(photo);
  }
}
 

Example 81

From project flexmojos, under directory /flexmojos-testing/flexmojos-test-harness/src/test/java/net/flexmojos/oss/test/.

Source file: FMVerifier.java

  16 
vote

private static void addMetadataToList(File dir,boolean hasCommand,List<String> l,String command){
  if (dir.exists() && dir.isDirectory()) {
    String[] files=dir.list(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.startsWith("maven-metadata") && name.endsWith(".xml");
      }
    }
);
    for (int i=0; i < files.length; i++) {
      if (hasCommand) {
        l.add(command + " " + new File(dir,files[i]).getPath());
      }
 else {
        l.add(new File(dir,files[i]).getPath());
      }
    }
  }
}
 

Example 82

From project FlipDroid, under directory /web-image-view/src/main/java/com/goal98/android/.

Source file: CacheHelper.java

  16 
vote

private static void removeExpiredCache(final AbstractCache<String,?> cache,final String urlPrefix){
  final File cacheDir=new File(cache.getDiskCacheDirectory());
  if (!cacheDir.exists()) {
    return;
  }
  File[] list=cacheDir.listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String filename){
      return dir.equals(cacheDir) && filename.startsWith(cache.getFileNameForKey(urlPrefix));
    }
  }
);
  if (list == null || list.length == 0) {
    return;
  }
  for (  File file : list) {
    file.delete();
  }
}
 

Example 83

From project flyingsaucer, under directory /flying-saucer-core/src/main/java/org/xhtmlrenderer/test/.

Source file: AllPageTest.java

  16 
vote

public void run(){
  try {
    String demosDir="d:/java/javanet/xhtmlrenderer/demos/browser/xhtml/new";
    File[] files=new File(demosDir).listFiles(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.endsWith("xhtml");
      }
    }
);
    for (int i=0; i < files.length; i++) {
      File file=files[i];
      try {
        render(file);
      }
 catch (      Exception ex) {
        ex.printStackTrace();
      }
    }
  }
 catch (  Exception ex) {
    ex.printStackTrace();
  }
}
 

Example 84

From project flyway, under directory /flyway-commandline/src/main/java/com/googlecode/flyway/commandline/.

Source file: Main.java

  16 
vote

/** 
 * Loads all the jars contained in the jars folder. (For Jdbc drivers and Java Migrations)
 * @throws IOException When the jars could not be loaded.
 */
private static void loadJdbcDriversAndJavaMigrations() throws Exception {
  final String directoryForJdbcDriversAndJavaMigrations=getInstallationDir() + "/jars";
  File dir=new File(directoryForJdbcDriversAndJavaMigrations);
  File[] files=dir.listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(".jar");
    }
  }
);
  if (files == null) {
    LOG.warn("Directory for JDBC drivers and JavaMigrations not found: " + directoryForJdbcDriversAndJavaMigrations);
    return;
  }
  for (  File file : files) {
    addJarOrDirectoryToClasspath(file.getPath());
  }
}
 

Example 85

From project freemind, under directory /freemind/accessories/plugins/.

Source file: ExportWithXSLT.java

  16 
vote

/** 
 */
private void copyIconsToDirectory(String directoryName2){
  Vector iconNames=MindIcon.getAllIconNames();
  for (int i=0; i < iconNames.size(); ++i) {
    String iconName=((String)iconNames.get(i));
    MindIcon myIcon=MindIcon.factory(iconName);
    copyFromResource(MindIcon.getIconsPath(),myIcon.getIconBaseFileName(),directoryName2);
  }
  File iconDir=new File(Resources.getInstance().getFreemindDirectory(),"icons");
  if (iconDir.exists()) {
    String[] userIconArray=iconDir.list(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.matches(".*\\.png");
      }
    }
);
    for (int i=0; i < userIconArray.length; ++i) {
      String iconName=userIconArray[i];
      if (iconName.length() == 4) {
        continue;
      }
      copyFromFile(iconDir.getAbsolutePath(),iconName,directoryName2);
    }
  }
}
 

Example 86

From project GenericKnimeNodes, under directory /com.genericworkflownodes.knime.node_generator/src/org/ballproject/knime/nodegeneration/model/directories/source/.

Source file: PayloadDirectory.java

  16 
vote

/** 
 * Copies all valid ini and zip files to the specified  {@link File directory}.
 * @param destDir
 * @throws IOException
 */
public void copyPayloadTo(File destDir) throws IOException {
  for (  String filename : this.list(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String filename){
      if (filename.endsWith(".ini")) {
        return true;
      }
      if (filename.endsWith(".zip")) {
        return true;
      }
      return false;
    }
  }
)) {
    FileUtils.copyFileToDirectory(new File(this,filename),destDir);
  }
}
 

Example 87

From project GeoBI, under directory /print/src/test/java/apps/.

Source file: MosiacImages.java

  16 
vote

public static void main(String[] args) throws IOException {
  File[] imageFiles=new File("/tmp").listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.startsWith("pdf");
    }
  }
);
  ImageLayout layout=new ImageLayout();
  layout.setTileWidth(500);
  layout.setTileHeight(500);
  ParameterBlock pbMosaic=new ParameterBlock();
  float height=0;
  for (  File imageFile : imageFiles) {
    PlanarImage source=JAI.create("fileload",imageFile.getPath());
    ParameterBlock pbTranslate=new ParameterBlock();
    pbTranslate.addSource(source);
    pbTranslate.add(0f);
    pbTranslate.add(height);
    RenderedOp translated=JAI.create("translate",pbTranslate,new RenderingHints(JAI.KEY_IMAGE_LAYOUT,layout));
    pbMosaic.addSource(translated);
    height+=source.getHeight() + MARGIN;
  }
  RenderedOp mosaic=JAI.create("mosaic",pbMosaic,new RenderingHints(JAI.KEY_IMAGE_LAYOUT,layout));
  ImageIO.write(mosaic,"png",new File("/tmp/mosaic-img.png"));
}
 

Example 88

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

Source file: Build.java

  16 
vote

private static void removeObsoleteArtifacts(final MavenObject mo,final BuildType type,File folder){
  File[] removals=folder.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      String n=name.toLowerCase();
      String dep=mo.artifact.toLowerCase();
      if (n.startsWith(dep)) {
        String suffix="-" + mo.version;
        if (type.equals(BuildType.COMPILETIME)) {
          suffix+="-sources.jar";
        }
 else {
          suffix+=".jar";
        }
        if (!n.endsWith(suffix)) {
          return true;
        }
      }
      return false;
    }
  }
);
  if (removals != null) {
    for (    File file : removals) {
      System.out.println("deleting " + file);
      file.delete();
    }
  }
}
 

Example 89

From project GNDMS, under directory /infra/src/de/zib/gndms/infra/grams/.

Source file: AbstractDirectoryAux.java

  16 
vote

public boolean deleteFiles(String uid,String pth,String filter){
  File dir=new File(pth);
  if (!dir.exists())   throw new NoSuchResourceException("failed to delete files " + pth + File.separatorChar+ filter+ ": directory does not exist");
  if (!dir.isDirectory())   throw new NoSuchResourceException("failed to delete files " + pth + File.separatorChar+ filter+ ": "+ pth+ " is no directory");
  final Pattern regex=Pattern.compile(filter);
  File[] files=dir.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      Matcher matcher=regex.matcher(name);
      return matcher.matches();
    }
  }
);
  boolean success=true;
  for (  File f : files) {
    if (!f.delete())     success=false;
  }
  return success;
}
 

Example 90

From project grails-ide, under directory /org.grails.ide.eclipse.core/src/org/grails/ide/eclipse/core/internal/classpath/.

Source file: GrailsPluginsListManager.java

  16 
vote

/** 
 * Get all the files the xml files that contain plugin lists. This operation may fail and return null a number of reasons: - the plugins directory could not be determined because the project's dependency data has not yet been generated - the plugins files have not yet been generated by grails.
 * @param pluginsFolder
 * @return
 */
private File[] getPluginsListFiles(){
  File[] pluginsFiles;
  pluginsFiles=null;
  String pluginsDirectory=GrailsPluginUtil.getGrailsWorkDir(project);
  if (pluginsDirectory != null) {
    File pluginsFolder=new File(pluginsDirectory);
    if (pluginsFolder.exists() && pluginsFolder.isDirectory() && pluginsFolder.canRead()) {
      pluginsFiles=pluginsFolder.listFiles(new FilenameFilter(){
        public boolean accept(        File dir,        String name){
          return name.startsWith("plugins-list-") && name.endsWith(".xml");
        }
      }
);
    }
  }
  return pluginsFiles;
}
 

Example 91

From project grails-maven, under directory /src/main/java/org/grails/maven/plugin/tools/.

Source file: DefaultGrailsServices.java

  16 
vote

public GrailsPluginProject readGrailsPluginProject() throws MojoExecutionException {
  final GrailsPluginProject pluginProject=new GrailsPluginProject();
  final File[] files=getBasedir().listFiles(new FilenameFilter(){
    public boolean accept(    final File file,    final String s){
      return s.endsWith(FILE_SUFFIX) && s.length() > FILE_SUFFIX.length();
    }
  }
);
  if (files == null || files.length != 1) {
    throw new MojoExecutionException("Could not find a plugin descriptor. Expected to find exactly one file " + "called FooGrailsPlugin.groovy in '" + getBasedir().getAbsolutePath() + "'.");
  }
  final File descriptor=files[0];
  pluginProject.setFileName(descriptor);
  final String className=descriptor.getName().substring(0,descriptor.getName().length() - ".groovy".length());
  final String pluginName=GrailsNameUtils.getScriptName(GrailsNameUtils.getLogicalName(className,"GrailsPlugin"));
  pluginProject.setPluginName(pluginName);
  final GroovyClassLoader classLoader=new GroovyClassLoader();
  final AstPluginDescriptorReader reader=new AstPluginDescriptorReader(classLoader);
  final GrailsPluginInfo info=reader.readPluginInfo(new org.codehaus.groovy.grails.io.support.FileSystemResource(descriptor));
  final String version=info.getVersion();
  if (version == null || version.trim().length() == 0) {
    throw new MojoExecutionException("Plugin does not have a version!");
  }
  pluginProject.setVersion(version);
  return pluginProject;
}
 

Example 92

From project griffon, under directory /subprojects/griffon-cli/src/main/groovy/griffon/ant/.

Source file: GriffonTask.java

  16 
vote

private List<URL> getRequiredLibsFromHome(){
  List<URL> urls=new ArrayList<URL>();
  try {
    File[] files=new File(home,"lib").listFiles(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.startsWith("gant_") || name.startsWith("groovy-all");
      }
    }
);
    for (    File file : files) {
      urls.add(file.toURI().toURL());
    }
    files=new File(home,"dist").listFiles(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.startsWith("griffon-bootstrap");
      }
    }
);
    for (    File file : files) {
      urls.add(file.toURI().toURL());
    }
    return urls;
  }
 catch (  MalformedURLException e) {
    throw new RuntimeException(e);
  }
}
 

Example 93

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

Source file: MemoryFileSystemTest.java

  16 
vote

@Test public void testList_FilenameFilter() throws IOException {
  final 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());
  String[] files=dir.list(new FilenameFilter(){
    @Override public boolean accept(    File d,    String name){
      assertEquals(dir,d);
      return !"d".equals(name);
    }
  }
);
  assertEquals(2,files.length);
  assertEquals("c",files[0]);
  assertEquals("f",files[1]);
}
 

Example 94

From project HiTune_1, under directory /chukwa-hitune-dist/src/java/org/apache/hadoop/chukwa/datacollection/agent/.

Source file: ChukwaAgent.java

  16 
vote

/** 
 * Tries to restore from a checkpoint file in checkpointDir. There should usually only be one checkpoint present -- two checkpoints present implies a crash during writing the higher-numbered one. As a result, this method chooses the lowest-numbered file present. Lines in the checkpoint file are processed one at a time with processCommand();
 * @return true if the restore succeeded
 * @throws IOException
 */
private boolean restoreFromCheckpoint() throws IOException {
synchronized (checkpointDir) {
    String[] checkpointNames=checkpointDir.list(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.startsWith(CHECKPOINT_BASE_NAME);
      }
    }
);
    if (checkpointNames == null) {
      log.error("Unable to list files in checkpoint dir");
      return false;
    }
    if (checkpointNames.length == 0) {
      log.info("No checkpoints found in " + checkpointDir);
      return false;
    }
    if (checkpointNames.length > 2)     log.warn("expected at most two checkpoint files in " + checkpointDir + "; saw "+ checkpointNames.length);
 else     if (checkpointNames.length == 0)     return false;
    String lowestName=null;
    int lowestIndex=Integer.MAX_VALUE;
    for (    String n : checkpointNames) {
      int index=Integer.parseInt(n.substring(CHECKPOINT_BASE_NAME.length()));
      if (index < lowestIndex) {
        lowestName=n;
        lowestIndex=index;
      }
    }
    checkpointNumber=lowestIndex + 1;
    File checkpoint=new File(checkpointDir,lowestName);
    readAdaptorsFile(checkpoint);
  }
  return true;
}
 

Example 95

From project hudson-test-harness, under directory /src/test/java/hudson/maven/.

Source file: Maven3BuildTest.java

  16 
vote

public void ignore_testSimpleMaven3BuildRedeployPublisher() throws Exception {
  MavenModuleSet m=createMavenProject();
  MavenInstallation mavenInstallation=configureMaven3();
  m.setMaven(mavenInstallation.getName());
  File repo=createTmpDir();
  FileUtils.cleanDirectory(repo);
  m.getReporters().add(new TestReporter());
  m.getPublishersList().add(new RedeployPublisher("",repo.toURI().toString(),true,false));
  m.setScm(new ExtractResourceSCM(getClass().getResource("maven3-project.zip")));
  m.setGoals("clean install");
  MavenModuleSetBuild b=buildAndAssertSuccess(m);
  assertTrue(MavenUtil.maven3orLater(b.getMavenVersionUsed()));
  File artifactDir=new File(repo,"com/mycompany/app/my-app/1.7-SNAPSHOT/");
  String[] files=artifactDir.list(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      System.out.println("file name : " + name);
      return name.endsWith(".jar");
    }
  }
);
  assertTrue("SNAPSHOT exist",!files[0].contains("SNAPSHOT"));
  assertTrue("file not ended with -1.jar",files[0].endsWith("-1.jar"));
}
 

Example 96

From project ignition, under directory /ignition-support/ignition-support-lib/src/main/java/com/github/ignition/support/cache/.

Source file: CacheHelper.java

  16 
vote

private static void removeExpiredCache(final AbstractCache<String,?> cache,final String urlPrefix){
  final File cacheDir=new File(cache.getDiskCacheDirectory());
  if (!cacheDir.exists()) {
    return;
  }
  File[] list=cacheDir.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String filename){
      return dir.equals(cacheDir) && filename.startsWith(cache.getFileNameForKey(urlPrefix));
    }
  }
);
  if (list == null || list.length == 0) {
    return;
  }
  for (  File file : list) {
    file.delete();
  }
}
 

Example 97

From project iJetty, under directory /i-jetty/i-jetty-server/src/main/java/org/mortbay/ijetty/deployer/.

Source file: AndroidContextDeployer.java

  16 
vote

/** 
 * Start the hot deployer looking for webapps to deploy/undeploy
 * @see org.mortbay.component.AbstractLifeCycle#doStart()
 */
@Override protected void doStart() throws Exception {
  if (_configurationDir == null) {
    Log.warn("No configuration dir specified");
    throw new IllegalStateException("No configuration dir specified");
  }
  if (_contexts == null) {
    throw new IllegalStateException("No context handler collection specified for deployer");
  }
  _scanner.setScanDirs(Collections.singletonList(_configurationDir.getFile()));
  _scanner.setScanInterval(getScanInterval());
  _scanner.setRecursive(_recursive);
  _scanner.setFilenameFilter(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      try {
        if (name.endsWith(".xml") && dir.equals(getConfigurationDir().getFile())) {
          return true;
        }
        return false;
      }
 catch (      IOException e) {
        Log.warn(e);
        return false;
      }
    }
  }
);
  _scannerListener=new ScannerListener();
  _scanner.addListener(_scannerListener);
  _scanner.scan();
  _scanner.start();
  _contexts.getServer().getContainer().addBean(_scanner);
}
 

Example 98

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 99

From project java-psd-library, under directory /psd-tool/src/psdtool/.

Source file: MainFrame.java

  16 
vote

@Override public void actionPerformed(ActionEvent e){
  FileDialog fileDialog=new FileDialog(frame,"Open psd file",FileDialog.LOAD);
  fileDialog.setDirectory("~/Downloads");
  fileDialog.setFilenameFilter(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.toLowerCase().endsWith(".psd");
    }
  }
);
  fileDialog.setVisible(true);
  if (fileDialog.getFile() != null) {
    File directory=new File(fileDialog.getDirectory());
    File psdFile=new File(directory,fileDialog.getFile());
    try {
      Psd psd=new Psd(psdFile);
      treeLayerModel.setPsd(psd);
      psdView.setPsd(psd);
    }
 catch (    IOException ex) {
      throw new RuntimeException(ex);
    }
  }
}
 

Example 100

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

Source file: ScpUploadTask.java

  16 
vote

/** 
 * Collects files under the given path that match the provided regex. If recurse is set to true, this method will scan into every directory under the starting path to collect files. If recurse is false, only the root path is scanned. 
 * @param path path to scan
 * @param fileRegex regular expression to identify matching files for upload
 * @param recurse if true, recurse into all directories under the starting path
 * @return files matching the fileRegex regular expression
 */
public List<File> collectFiles(File path,final String fileRegex,final boolean recurse){
  LOG.debug(path.getPath());
  List<File> files=new ArrayList<File>();
  final List<File> directories=new ArrayList<File>();
  File[] tmp=path.listFiles(new FilenameFilter(){
    public boolean accept(    File parent,    String filename){
      File file=new File(parent.getPath() + File.separator + filename);
      if (recurse && file.isDirectory())       directories.add(file);
      return file.getPath().matches(fileRegex);
    }
  }
);
  files.addAll(Arrays.asList(tmp));
  if (recurse) {
    for (    File file : directories) {
      if (file.isDirectory()) {
        files.addAll(collectFiles(file,fileRegex,recurse));
      }
    }
  }
  return files;
}
 

Example 101

From project jbosgi-framework, under directory /aggregated/src/test/java/org/jboss/test/osgi/framework/launch/.

Source file: AggregatedFrameworkLaunchTestCase.java

  16 
vote

@Test public void testAggregatedFrameworkLaunch() throws Exception {
  File[] files=new File("./target").listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.startsWith("jbosgi-framework-aggregated-") && name.endsWith("-all.jar");
    }
  }
);
  assertEquals("Aggregated file exists: " + Arrays.asList(files),1,files.length);
  assertTrue("File.length > 1M",files[0].length() > 1024 * 1014L);
  File logManagerJar=new File("target/test-libs/jboss-logmanager.jar");
  assertTrue("File exists: " + logManagerJar,logManagerJar.exists());
  File logConfig=new File("target/test-classes/logging.properties");
  assertTrue("File exists: " + logConfig,logConfig.exists());
  String jars=files[0].getCanonicalPath() + File.pathSeparator + logManagerJar.getCanonicalPath();
  String logopts="-Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dlogging.configuration=" + logConfig.toURI();
  String javaopts=logopts + " -Dorg.osgi.framework.storage=target/osgi-store";
  String cmd="java " + javaopts + " -cp "+ jars+ " "+ FrameworkMain.class.getName();
  Process proc=Runtime.getRuntime().exec(cmd);
  Thread.sleep(3000);
  proc.destroy();
  File logfile=new File("./target/test.log");
  assertTrue("Logfile exists: " + logfile,logfile.exists());
}
 

Example 102

From project jena-examples, under directory /src/main/java/org/apache/jena/examples/.

Source file: ExampleARQ_05.java

  16 
vote

public static void main(String[] args){
  FileManager.get().addLocatorClassLoader(ExampleARQ_01.class.getClassLoader());
  Model model=FileManager.get().loadModel("data/data.ttl");
  System.out.println("Input data:");
  model.write(System.out,"TURTLE");
  File path=new File("src/main/resources/data/queries");
  File[] files=path.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.startsWith("construct-") && name.endsWith(".sparql");
    }
  }
);
  Arrays.sort(files);
  for (  File file : files) {
    System.out.println("Executing " + file.getName() + " ...");
    Query query=QueryFactory.read(file.getAbsolutePath());
    QueryExecution qexec=QueryExecutionFactory.create(query,model);
    try {
      Model result=qexec.execConstruct();
      model.add(result);
    }
  finally {
      qexec.close();
    }
  }
  System.out.println("Output data:");
  model.write(System.out,"TURTLE");
}
 

Example 103

From project JGit, under directory /org.spearce.jgit/src/org/spearce/jgit/lib/.

Source file: Repository.java

  16 
vote

private void scanForPacks(final File packDir,Collection<PackFile> packList){
  final String[] idxList=packDir.list(new FilenameFilter(){
    public boolean accept(    final File baseDir,    final String n){
      return n.length() == 49 && n.endsWith(".idx") && n.startsWith("pack-");
    }
  }
);
  if (idxList != null) {
    SCAN:     for (    final String indexName : idxList) {
      final String n=indexName.substring(0,indexName.length() - 4);
      final File idxFile=new File(packDir,n + ".idx");
      final File packFile=new File(packDir,n + ".pack");
      if (!packFile.isFile()) {
        continue;
      }
      for (      final PackFile p : packList) {
        if (packFile.equals(p.getPackFile()))         continue SCAN;
      }
      packList.add(new PackFile(idxFile,packFile));
    }
  }
}
 

Example 104

From project jgraphx, under directory /examples/com/mxgraph/examples/swing/editor/.

Source file: EditorActions.java

  16 
vote

/** 
 */
public void actionPerformed(ActionEvent e){
  BasicGraphEditor editor=getEditor(e);
  if (editor != null) {
    String wd=(lastDir != null) ? lastDir : System.getProperty("user.dir");
    JFileChooser fc=new JFileChooser(wd);
    fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fc.addChoosableFileFilter(new DefaultFileFilter(".shape","Dia Shape " + mxResources.get("file") + " (.shape)"));
    int rc=fc.showDialog(null,mxResources.get("importStencil"));
    if (rc == JFileChooser.APPROVE_OPTION) {
      lastDir=fc.getSelectedFile().getParent();
      try {
        if (fc.getSelectedFile().isDirectory()) {
          EditorPalette palette=editor.insertPalette(fc.getSelectedFile().getName());
          for (          File f : fc.getSelectedFile().listFiles(new FilenameFilter(){
            public boolean accept(            File dir,            String name){
              return name.toLowerCase().endsWith(".shape");
            }
          }
)) {
            String nodeXml=mxUtils.readFile(f.getAbsolutePath());
            addStencilShape(palette,nodeXml,f.getParent() + File.separator);
          }
          JComponent scrollPane=(JComponent)palette.getParent().getParent();
          editor.getLibraryPane().setSelectedComponent(scrollPane);
        }
 else {
          String nodeXml=mxUtils.readFile(fc.getSelectedFile().getAbsolutePath());
          String name=addStencilShape(null,nodeXml,null);
          JOptionPane.showMessageDialog(editor,mxResources.get("stencilImported",new String[]{name}));
        }
      }
 catch (      IOException e1) {
        e1.printStackTrace();
      }
    }
  }
}
 

Example 105

From project jmd, under directory /src/org/apache/bcel/util/.

Source file: ClassPath.java

  16 
vote

/** 
 * Checks for class path components in the following properties: "java.class.path", "sun.boot.class.path", "java.ext.dirs"
 * @return class path as used by default by BCEL
 */
public static final String getClassPath(){
  String class_path=System.getProperty("java.class.path");
  String boot_path=System.getProperty("sun.boot.class.path");
  String ext_path=System.getProperty("java.ext.dirs");
  List list=new ArrayList();
  getPathComponents(class_path,list);
  getPathComponents(boot_path,list);
  List dirs=new ArrayList();
  getPathComponents(ext_path,dirs);
  for (Iterator e=dirs.iterator(); e.hasNext(); ) {
    File ext_dir=new File((String)e.next());
    String[] extensions=ext_dir.list(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        name=name.toLowerCase(Locale.ENGLISH);
        return name.endsWith(".zip") || name.endsWith(".jar");
      }
    }
);
    if (extensions != null) {
      for (int i=0; i < extensions.length; i++) {
        list.add(ext_dir.getPath() + File.separatorChar + extensions[i]);
      }
    }
  }
  StringBuffer buf=new StringBuffer();
  for (Iterator e=list.iterator(); e.hasNext(); ) {
    buf.append((String)e.next());
    if (e.hasNext()) {
      buf.append(File.pathSeparatorChar);
    }
  }
  return buf.toString().intern();
}
 

Example 106

From project jmeter-sla-report, under directory /src/java/org/apache/jmeter/extra/report/sla/.

Source file: JMeterReportParser.java

  16 
vote

public List<File> getSourceFiles(){
  List<File> result=new ArrayList<File>();
  for (  File sourceFile : sourceFiles) {
    if (sourceFile.isFile()) {
      result.add(sourceFile);
    }
 else {
      String[] listedFiles=sourceFile.list(new FilenameFilter(){
        public boolean accept(        File dir,        String name){
          String lowerName=name.toLowerCase();
          boolean isJtl=lowerName.endsWith(".jtl");
          boolean isCsv=lowerName.endsWith(".csv");
          return isJtl || isCsv;
        }
      }
);
      for (      String listedFile : listedFiles) {
        result.add(new File(listedFile));
      }
    }
  }
  return result;
}
 

Example 107

From project jodconverter, under directory /jodconverter-core/src/test/java/org/artofsolving/jodconverter/.

Source file: OfficeDocumentConverterFunctionalTest.java

  16 
vote

public void runAllPossibleConversions() throws IOException {
  OfficeManager officeManager=new DefaultOfficeManagerConfiguration().buildOfficeManager();
  OfficeDocumentConverter converter=new OfficeDocumentConverter(officeManager);
  DocumentFormatRegistry formatRegistry=converter.getFormatRegistry();
  officeManager.start();
  try {
    File dir=new File("src/test/resources/documents");
    File[] files=dir.listFiles(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return !name.startsWith(".");
      }
    }
);
    for (    File inputFile : files) {
      String inputExtension=FilenameUtils.getExtension(inputFile.getName());
      DocumentFormat inputFormat=formatRegistry.getFormatByExtension(inputExtension);
      assertNotNull(inputFormat,"unknown input format: " + inputExtension);
      Set<DocumentFormat> outputFormats=formatRegistry.getOutputFormats(inputFormat.getInputFamily());
      for (      DocumentFormat outputFormat : outputFormats) {
        File outputFile=File.createTempFile("test","." + outputFormat.getExtension());
        outputFile.deleteOnExit();
        System.out.printf("-- converting %s to %s... ",inputFormat.getExtension(),outputFormat.getExtension());
        converter.convert(inputFile,outputFile,outputFormat);
        System.out.printf("done.\n");
        assertTrue(outputFile.isFile() && outputFile.length() > 0);
      }
    }
  }
  finally {
    officeManager.stop();
  }
}
 

Example 108

From project jodconverter_1, under directory /jodconverter-core/src/test/java/org/artofsolving/jodconverter/.

Source file: OfficeDocumentConverterFunctionalTest.java

  16 
vote

public void runAllPossibleConversions() throws IOException {
  OfficeManager officeManager=new DefaultOfficeManagerConfiguration().buildOfficeManager();
  OfficeDocumentConverter converter=new OfficeDocumentConverter(officeManager);
  DocumentFormatRegistry formatRegistry=converter.getFormatRegistry();
  officeManager.start();
  try {
    File dir=new File("src/test/resources/documents");
    File[] files=dir.listFiles(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return !name.startsWith(".");
      }
    }
);
    for (    File inputFile : files) {
      String inputExtension=FilenameUtils.getExtension(inputFile.getName());
      DocumentFormat inputFormat=formatRegistry.getFormatByExtension(inputExtension);
      assertNotNull(inputFormat,"unknown input format: " + inputExtension);
      Set<DocumentFormat> outputFormats=formatRegistry.getOutputFormats(inputFormat.getInputFamily());
      for (      DocumentFormat outputFormat : outputFormats) {
        File outputFile=File.createTempFile("test","." + outputFormat.getExtension());
        outputFile.deleteOnExit();
        System.out.printf("-- converting %s to %s... ",inputFormat.getExtension(),outputFormat.getExtension());
        converter.convert(inputFile,outputFile,outputFormat);
        System.out.printf("done.\n");
        assertTrue(outputFile.isFile() && outputFile.length() > 0);
      }
    }
  }
  finally {
    officeManager.stop();
  }
}
 

Example 109

From project karaf, under directory /instance/core/src/main/java/org/apache/karaf/instance/core/internal/.

Source file: InstanceImpl.java

  16 
vote

private String createClasspathFromAllJars(File libDir) throws IOException {
  File[] jars=libDir.listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(".jar");
    }
  }
);
  StringBuilder classpath=new StringBuilder();
  for (  File jar : jars) {
    if (classpath.length() > 0) {
      classpath.append(System.getProperty("path.separator"));
    }
    classpath.append(jar.getCanonicalPath());
  }
  return classpath.toString();
}
 

Example 110

From project koneki.ldt, under directory /plugins/org.eclipse.koneki.ldt/src/org/eclipse/koneki/ldt/core/internal/buildpath/.

Source file: LuaExecutionEnvironmentManager.java

  16 
vote

private static LuaExecutionEnvironment getExecutionEnvironmentFromDir(final File executionEnvironmentDirectory) throws CoreException {
  if (!executionEnvironmentDirectory.exists() || !executionEnvironmentDirectory.isDirectory())   return null;
  String manifestString=null;
  File[] manifests=executionEnvironmentDirectory.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.endsWith(LuaExecutionEnvironmentConstants.MANIFEST_EXTENSION);
    }
  }
);
  if (manifests == null || manifests.length != 1) {
    final String message=MessageFormat.format("0 or more than 1 \"{0}\" file in given file.",LuaExecutionEnvironmentConstants.MANIFEST_EXTENSION);
    throwException(message,null,IStatus.ERROR);
  }
  InputStream manifestInputStream=null;
  try {
    manifestInputStream=new FileInputStream(manifests[0]);
    manifestString=IOUtils.toString(manifestInputStream);
  }
 catch (  IOException e) {
    throwException("Unable to read manifest file.",e,IStatus.ERROR);
  }
 finally {
    if (manifestInputStream != null)     try {
      manifestInputStream.close();
    }
 catch (    IOException e) {
      Activator.logWarning(MessageFormat.format("Unable to close file {0}",manifests[0]),e);
    }
  }
  return getLuaExecutionEnvironmentFromManifest(manifestString,new Path(executionEnvironmentDirectory.getPath()));
}
 

Example 111

From project lib-jenkins-maven-embedder, under directory /src/main/java/hudson/maven/.

Source file: MavenEmbedderUtils.java

  16 
vote

/** 
 * <p> build a  {@link ClassRealm} with all jars in mavenHome/lib/*.jar</p> <p> the  {@link ClassRealm} is ChildFirst with the current classLoader as parent.</p> 
 * @param mavenHome cannot be <code>null</code>
 * @param world can be <code>null</code>
 * @return
 */
public static ClassRealm buildClassRealm(File mavenHome,ClassWorld world,ClassLoader parentClassLoader) throws MavenEmbedderException {
  if (mavenHome == null) {
    throw new IllegalArgumentException("mavenHome cannot be null");
  }
  if (!mavenHome.exists()) {
    throw new IllegalArgumentException("mavenHome '" + mavenHome.getPath() + "' doesn't seem to exist on this node (or you don't have sufficient rights to access it)");
  }
  File libDirectory=new File(mavenHome,"lib");
  if (!libDirectory.exists()) {
    throw new IllegalArgumentException(mavenHome.getPath() + " doesn't have a 'lib' subdirectory - thus cannot be a valid maven installation!");
  }
  File[] jarFiles=libDirectory.listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.endsWith(".jar");
    }
  }
);
  AntClassLoader antClassLoader=new AntClassLoader(Thread.currentThread().getContextClassLoader(),false);
  for (  File jarFile : jarFiles) {
    antClassLoader.addPathComponent(jarFile);
  }
  if (world == null) {
    world=new ClassWorld();
  }
  ClassRealm classRealm=new ClassRealm(world,"plexus.core",parentClassLoader == null ? antClassLoader : parentClassLoader);
  for (  File jarFile : jarFiles) {
    try {
      classRealm.addURL(jarFile.toURI().toURL());
    }
 catch (    MalformedURLException e) {
      throw new MavenEmbedderException(e.getMessage(),e);
    }
  }
  return classRealm;
}
 

Example 112

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 113

From project mapfish-print, under directory /src/test/java/apps/.

Source file: MosiacImages.java

  16 
vote

public static void main(String[] args) throws IOException {
  File[] imageFiles=new File("/tmp").listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.startsWith("pdf");
    }
  }
);
  ImageLayout layout=new ImageLayout();
  layout.setTileWidth(500);
  layout.setTileHeight(500);
  ParameterBlock pbMosaic=new ParameterBlock();
  float height=0;
  for (  File imageFile : imageFiles) {
    PlanarImage source=JAI.create("fileload",imageFile.getPath());
    ParameterBlock pbTranslate=new ParameterBlock();
    pbTranslate.addSource(source);
    pbTranslate.add(0f);
    pbTranslate.add(height);
    RenderedOp translated=JAI.create("translate",pbTranslate,new RenderingHints(JAI.KEY_IMAGE_LAYOUT,layout));
    pbMosaic.addSource(translated);
    height+=source.getHeight() + MARGIN;
  }
  RenderedOp mosaic=JAI.create("mosaic",pbMosaic,new RenderingHints(JAI.KEY_IMAGE_LAYOUT,layout));
  ImageIO.write(mosaic,"png",new File("/tmp/mosaic-img.png"));
}
 

Example 114

From project mapfish-print_1, under directory /src/test/java/apps/.

Source file: MosiacImages.java

  16 
vote

public static void main(String[] args) throws IOException {
  File[] imageFiles=new File("/tmp").listFiles(new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      return name.startsWith("pdf");
    }
  }
);
  ImageLayout layout=new ImageLayout();
  layout.setTileWidth(500);
  layout.setTileHeight(500);
  ParameterBlock pbMosaic=new ParameterBlock();
  float height=0;
  for (  File imageFile : imageFiles) {
    PlanarImage source=JAI.create("fileload",imageFile.getPath());
    ParameterBlock pbTranslate=new ParameterBlock();
    pbTranslate.addSource(source);
    pbTranslate.add(0f);
    pbTranslate.add(height);
    RenderedOp translated=JAI.create("translate",pbTranslate,new RenderingHints(JAI.KEY_IMAGE_LAYOUT,layout));
    pbMosaic.addSource(translated);
    height+=source.getHeight() + MARGIN;
  }
  RenderedOp mosaic=JAI.create("mosaic",pbMosaic,new RenderingHints(JAI.KEY_IMAGE_LAYOUT,layout));
  ImageIO.write(mosaic,"png",new File("/tmp/mosaic-img.png"));
}
 

Example 115

From project maven-shared, under directory /maven-verifier/src/main/java/org/apache/maven/it/.

Source file: Verifier.java

  16 
vote

private static void addMetadataToList(File dir,boolean hasCommand,List l,String command){
  if (dir.exists() && dir.isDirectory()) {
    String[] files=dir.list(new FilenameFilter(){
      public boolean accept(      File dir,      String name){
        return name.startsWith("maven-metadata") && name.endsWith(".xml");
      }
    }
);
    for (int i=0; i < files.length; i++) {
      if (hasCommand) {
        l.add(command + " " + new File(dir,files[i]).getPath());
      }
 else {
        l.add(new File(dir,files[i]).getPath());
      }
    }
  }
}
 

Example 116

From project MediaButtons, under directory /src/com/github/mediabuttons/.

Source file: ZipImageSource.java

  16 
vote

/** 
 * Read through the themes directory to find all *.zip files.  We do not do any further validation of the theme files.
 * @param themes  The vector to append themes to.
 */
public static void appendToThemeList(Vector<ThemeId> themes){
  File base_dir=Environment.getExternalStorageDirectory();
  File theme_dir=new File(base_dir,"Android/data/com.github.mediabuttons/themes");
  String[] zip_files=theme_dir.list(new FilenameFilter(){
    public boolean accept(    File dir,    String filename){
      return filename.endsWith(".zip");
    }
  }
);
  if (zip_files == null) {
    return;
  }
  themes.ensureCapacity(themes.size() + zip_files.length);
  for (int i=0; i < zip_files.length; ++i) {
    String name=zip_files[i];
    ThemeId theme=new ThemeId(name.substring(0,name.length() - 4),theme_dir.getPath() + "/" + name);
    themes.add(theme);
  }
}
 

Example 117

From project Metamorphosis, under directory /metamorphosis-server/src/main/java/com/taobao/metamorphosis/server/transaction/store/.

Source file: Checkpoint.java

  16 
vote

private synchronized void recover() throws Exception {
  log.info("Begin to recover checkpoint journal...");
  final File[] ls=this.transactionsDir.listFiles(new FilenameFilter(){
    @Override public boolean accept(    final File dir,    final String name){
      return name.startsWith(FILE_PREFIX);
    }
  }
);
  Arrays.sort(ls,new Comparator<File>(){
    @Override public int compare(    final File o1,    final File o2){
      return Checkpoint.this.getFileNumber(o1) - Checkpoint.this.getFileNumber(o2);
    }
  }
);
  if (ls != null && ls.length > 0) {
    for (    final File file : ls) {
      final DataFile df=new DataFile(file,this.getFileNumber(file),true);
      this.addCheckpoint(df);
    }
  }
  if (this.currCheckpoint == null) {
    this.newCheckpoint();
  }
 else {
    this.number.set(this.currCheckpoint.getNumber());
    this.lastLocation=this.readLocation(this.currCheckpoint);
  }
  log.info("Recover checkpoint journal succesfully");
}
 

Example 118

From project AuToBI, under directory /src/edu/cuny/qc/speech/AuToBI/util/.

Source file: AuToBIUtils.java

  15 
vote

/** 
 * Recursively generates the list of files within directory that match the file_pattern
 * @param dir          The directory
 * @param file_pattern The filename pattern
 * @return A list of file names  in the directory that match the patter
 */
public static List<String> getFileList(File dir,String file_pattern){
  ArrayList<String> file_names=new ArrayList<String>();
  String[] path_elements=file_pattern.split("/");
  if (path_elements[0].equals(".")) {
    String next_file_pattern=construct_path_string(path_elements);
    file_names.addAll(getFileList(dir,next_file_pattern));
  }
 else   if (path_elements[0].equals("..")) {
    String next_file_pattern=construct_path_string(path_elements);
    file_names.addAll(getFileList(dir.getParentFile(),next_file_pattern));
  }
 else {
    GlobFilenameFilter filter=new GlobFilenameFilter(path_elements[0]);
    File[] files=dir.listFiles((FilenameFilter)filter);
    for (    File f : files) {
      if (path_elements.length > 1) {
        if (f.exists() && f.isDirectory()) {
          String next_file_pattern=construct_path_string(path_elements);
          file_names.addAll(getFileList(f,next_file_pattern));
        }
      }
 else {
        if (f.exists()) {
          file_names.add(f.getAbsolutePath());
        }
      }
    }
  }
  return file_names;
}
 

Example 119

From project avro, under directory /lang/java/tools/src/main/java/org/apache/avro/tool/.

Source file: SpecificCompilerTool.java

  15 
vote

/** 
 * For a List of files or directories, returns a File[] containing each file passed as well as each file with a matching extension found in the directory.
 * @param inputs List of File objects that are files or directories
 * @param filter File extension filter to match on when fetching files from a directory
 * @return Unique array of files
 */
private static File[] determineInputs(List<File> inputs,FilenameFilter filter){
  Set<File> fileSet=new LinkedHashSet<File>();
  for (  File file : inputs) {
    if (file.isDirectory()) {
      for (      File f : file.listFiles(filter)) {
        fileSet.add(f);
      }
    }
 else {
      fileSet.add(file);
    }
  }
  if (fileSet.size() > 0) {
    System.err.println("Input files to compile:");
    for (    File file : fileSet) {
      System.err.println("  " + file);
    }
  }
 else {
    System.err.println("No input files found.");
  }
  return fileSet.toArray((new File[fileSet.size()]));
}
 

Example 120

From project babel, under directory /src/babel/util/misc/.

Source file: FileListSampled.java

  15 
vote

public FileListSampled(String dir,FilenameFilter nameFilter,double sampleRate){
  super(dir,nameFilter);
  m_nameFilter=nameFilter;
  m_dir=new File(dir);
  m_current=0;
  m_sampleRate=sampleRate;
  m_generator=new Random();
  m_useTitleFilter=false;
  m_fileTitles=new HashMap<String,Integer>();
}
 

Example 121

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

Source file: BatchIngestQueue.java

  15 
vote

/** 
 * @return
 */
public File[] getReadyIngestDirectories(){
  File[] batchDirs=this.queuedDirectory.listFiles(new FileFilter(){
    @Override public boolean accept(    File arg0){
      if (arg0.isDirectory()) {
        String[] readyFiles=arg0.list(new FilenameFilter(){
          @Override public boolean accept(          File dir,          String name){
            return (READY_FILE.equals(name));
          }
        }
);
        if (readyFiles != null && readyFiles.length > 0) {
          return true;
        }
      }
      return false;
    }
  }
);
  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 122

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 FilenameFilter.
 * @param filter  the filter to decorate
 */
public DelegateFileFilter(FilenameFilter filter){
  if (filter == null) {
    throw new IllegalArgumentException("The FilenameFilter must not be null");
  }
  this.filenameFilter=filter;
  this.fileFilter=null;
}
 

Example 123

From project FileExplorer, under directory /src/net/micode/fileexplorer/.

Source file: Util.java

  15 
vote

public static FileInfo GetFileInfo(File f,FilenameFilter filter,boolean showHidden){
  FileInfo lFileInfo=new FileInfo();
  String filePath=f.getPath();
  File lFile=new File(filePath);
  lFileInfo.canRead=lFile.canRead();
  lFileInfo.canWrite=lFile.canWrite();
  lFileInfo.isHidden=lFile.isHidden();
  lFileInfo.fileName=f.getName();
  lFileInfo.ModifiedDate=lFile.lastModified();
  lFileInfo.IsDir=lFile.isDirectory();
  lFileInfo.filePath=filePath;
  if (lFileInfo.IsDir) {
    int lCount=0;
    File[] files=lFile.listFiles(filter);
    if (files == null) {
      return null;
    }
    for (    File child : files) {
      if ((!child.isHidden() || showHidden) && Util.isNormalFile(child.getAbsolutePath())) {
        lCount++;
      }
    }
    lFileInfo.Count=lCount;
  }
 else {
    lFileInfo.fileSize=lFile.length();
  }
  return lFileInfo;
}
 

Example 124

From project gpslogger, under directory /GPSLogger/src/com/mendhak/gpslogger/senders/.

Source file: FileSenderFactory.java

  15 
vote

public static void SendFiles(Context applicationContext,IActionListener callback){
  final String currentFileName=Session.getCurrentFileName();
  File gpxFolder=new File(Environment.getExternalStorageDirectory(),"GPSLogger");
  if (!gpxFolder.exists()) {
    callback.OnFailure();
    return;
  }
  List<File> files=new ArrayList<File>(Arrays.asList(gpxFolder.listFiles(new FilenameFilter(){
    @Override public boolean accept(    File file,    String s){
      return s.contains(currentFileName) && !s.contains("zip");
    }
  }
)));
  if (files.size() == 0) {
    callback.OnFailure();
    return;
  }
  if (AppSettings.shouldSendZipFile()) {
    File zipFile=new File(gpxFolder.getPath(),currentFileName + ".zip");
    ArrayList<String> filePaths=new ArrayList<String>();
    for (    File f : files) {
      filePaths.add(f.getAbsolutePath());
    }
    Utilities.LogInfo("Zipping file");
    ZipHelper zh=new ZipHelper(filePaths.toArray(new String[filePaths.size()]),zipFile.getAbsolutePath());
    zh.Zip();
    files.add(zipFile);
  }
  List<IFileSender> senders=GetFileSenders(applicationContext,callback);
  for (  IFileSender sender : senders) {
    sender.UploadFile(files);
  }
}
 

Example 125

From project ib-ruby, under directory /misc/APIExamples-DL/src/com/ib/client/examples/util/.

Source file: ListTextFilesApp.java

  15 
vote

public static Collection<File> listFiles(File directory,FilenameFilter filter,boolean recurse){
  Vector<File> files=new Vector<File>();
  File[] entries=directory.listFiles();
  for (  File entry : entries) {
    if (filter == null || filter.accept(directory,entry.getName())) {
      files.add(entry);
    }
    if (recurse && entry.isDirectory()) {
      files.addAll(listFiles(entry,filter,recurse));
    }
  }
  return files;
}
 

Example 126

From project javadrop, under directory /src/main/java/org/javadrop/runner/impl/.

Source file: BaseRunnerStrategy.java

  15 
vote

/** 
 * Get a bunch of files from a given directory. Generally used to grab a set of generated files (libraries, e.g.)
 * @param dir Directory to grab the files from
 * @param optionalFilter Filter to decide what files to grab from the directory. May be null
 * @return Collection of files.
 */
protected Collection<File> getDirFiles(File dir,FilenameFilter optionalFilter){
  ArrayList<File> fileList=new ArrayList<File>();
  File[] dirList;
  if (optionalFilter == null) {
    dirList=dir.listFiles();
  }
 else {
    dirList=dir.listFiles(optionalFilter);
  }
  if (dirList == null) {
    get_log().warn("Directory is missing or empty: " + dir.getAbsolutePath());
    return fileList;
  }
  for (  File file : dirList) {
    fileList.add(file);
  }
  return fileList;
}
 

Example 127

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

Source file: ShareManager.java

  15 
vote

/** 
 * Adds new files or directories to share. If these files already exists in share (could be hidden) then they are skipped.
 * @param includes The list of files or directories to share.
 * @param excludes The list of files or directories to excludefrom <i>includes</i>.
 * @param filter This allows you to filter out files like ones which arehidden, etc. 
 * @param inside This is the virtual path in the file list where you want theshares to get added. If this is null then root of the file list is assumed. 
 * @throws HashException When exception occurs while starting hashing.
 * @throws ShareException When hashing is in progress since the last timethis method or  {@link #updateShare(Vector)} was called or <i>inside</i>path is not null and it is not found.
 */
public void addShare(List<File> includes,List<File> excludes,FilenameFilter filter,String inside) throws HashException, ShareException {
  if (shareWorker != null)   throw new ShareException(ShareException.Error.HASHING_JOB_IN_PROGRESS);
  FLDir root=null;
  if (inside != null) {
    FLInterface fi=ownFL.getFilelist().getChildInTree(FLDir.getDirNamesFromPath(sanitizeVirtualPath(inside)),true);
    if (fi == null || fi instanceof FLFile)     throw new ShareException(ShareException.Error.FILE_OR_DIR_NOT_FOUND);
    root=(FLDir)fi;
  }
  ShareAdder sa=new ShareAdder(includes,excludes,filter,root);
  shareWorker=sa;
  sa.addShare();
}
 

Example 128

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

Source file: JavaSecuredFile.java

  15 
vote

@Override public String[] list(FilenameFilter filter){
  try {
    return super.list(filter);
  }
 catch (  SecurityException ex) {
    return null;
  }
}
 

Example 129

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

Source file: PrivilegedFileHelper.java

  15 
vote

/** 
 * Get file's list in privileged mode.
 * @param file
 * @return
 */
public static String[] list(final File file,final FilenameFilter filter){
  PrivilegedAction<String[]> action=new PrivilegedAction<String[]>(){
    public String[] run(){
      return file.list(filter);
    }
  }
;
  return SecurityHelper.doPrivilegedAction(action);
}
 

Example 130

From project leveldb, under directory /leveldb/src/main/java/org/iq80/leveldb/util/.

Source file: FileUtils.java

  15 
vote

public static ImmutableList<File> listFiles(File dir,FilenameFilter filter){
  File[] files=dir.listFiles(filter);
  if (files == null) {
    return ImmutableList.of();
  }
  return ImmutableList.copyOf(files);
}