Package java.io

Examples of java.io.FileFilter


    private static long getDirectoryLastModified(final String path) {
      final File pck = new File(System.getProperty("user.dir") + path);
      if ( !pck.exists() || !pck.isDirectory() )
        return Long.MAX_VALUE;

      final File[] classes = pck.listFiles(new FileFilter() {
        public boolean accept(final File pathname) {
          return pathname.isFile() && pathname.getName().endsWith(".class");
        }
      });
View Full Code Here


     */
    private class ComponentMonitor implements Runnable {

        public void run() {
            try {
                File [] jars = componentDirectory.listFiles(new FileFilter() {
                    public boolean accept(File pathname) {
                        String fileName = pathname.getName().toLowerCase();
                        return (fileName.endsWith(".jar") || fileName.endsWith(".war"));
                    }
                });

                for (int i=0; i<jars.length; i++) {
                    File jarFile = jars[i];
                    String componentName = jarFile.getName().substring(
                            0, jarFile.getName().length()-4).toLowerCase();
                    // See if the JAR has already been exploded.
                    File dir = new File(componentDirectory, componentName);
                    // If the JAR hasn't been exploded, do so.
                    if (!dir.exists()) {
                        unzipComponent(componentName, jarFile, dir);
                    }
                    // See if the JAR is newer than the directory. If so, the component
                    // needs to be unloaded and then reloaded.
                    else if (jarFile.lastModified() > dir.lastModified()) {
                        unloadComponent(componentName);
                        // Ask the system to clean up references.
                        System.gc();
                        while (!deleteDir(dir)) {
                            manager.getLog().error("Error unloading component " + componentName + ". " +
                                    "Will attempt again momentarily.");
                            Thread.sleep(5000);
                        }
                        // Now unzip the component.
                        unzipComponent(componentName, jarFile, dir);
                    }
                }

                File [] dirs = componentDirectory.listFiles(new FileFilter() {
                    public boolean accept(File pathname) {
                        return pathname.isDirectory();
                    }
                });

View Full Code Here

        if (!libDirectory.exists()) {
            return null;
        }

        //try to get the gradle.jar. It'll be "gradle-[version].jar"
        File[] files = libDirectory.listFiles(new FileFilter() {
            public boolean accept(File file) {
                return GRADLE_CORE_PATTERN.matcher(file.getName()).matches();
            }
        });
View Full Code Here

    while (list_of_dirs.size() != 0) {
      if (work_on_files.stopTraverseDir())
        return;
      current_dir = list_of_dirs.poll();
      if (with_part_met_extension)
        list_of_files = current_dir.listFiles(new FileFilter() {
          public boolean accept(File file) {
            if (file.isDirectory())
              return true;
            if (file.getName().endsWith(PART_MET_EXTENSION))
              return true;
View Full Code Here

    System.out.format("%5d", have);
    System.out.print((want != have) ? "*" : " ");
  }

  public void readAll() throws IOException {
    readAllDir(testDir, new FileFilter() {

      public boolean accept(File pathname) {
        return pathname.getName().endsWith(".h5") || pathname.getName().endsWith(".he5");
      }
    });
View Full Code Here

    System.out.format("%5d", have);
    System.out.print((want != have) ? "*" : " ");
  }

  public void makeReadAndCountAll() throws IOException {
    testReadAndCountAllInDir("C:/data/hdf4/", new FileFilter() {
      public boolean accept(File pathname) {
        return pathname.getName().endsWith(".hdf") || pathname.getName().endsWith(".15");
      }
    }); // */
  }
View Full Code Here

    private boolean bOptSeen;
    private String epAddr;

    protected void start(String[] args) throws Exception {
        ProviderFactory ph = createProviderFactory();
        FileFilter jsFilter = new JSFilter();
        int i = 0;
        boolean fileSeen = false;
        boolean msgPrinted = false;
        for (;;) {
            if (i == args.length) {
                break;
            }
            if (args[i].startsWith("-")) {
                i = checkOption(args, i);
                if (verbose && !msgPrinted) {
                    msgPrinted = true;
                    System.out.println("entering server");
                }
            } else {
                File f = new File(args[i]);
                if (f.isFile() && jsFilter.accept(f)) {
                    fileSeen = true;
                    if (verbose) {
                        System.out.println("processing file " + f.getCanonicalPath());
                    }
                    ph.createAndPublish(f, epAddr, bOptSeen);
View Full Code Here

        if (renameConfig.isSearchSimiliarDirectoriesEnabled()
            && !result.exists()) {
          // If not exists and search is activated.
          final String directoryName = result.getName();
          File[] similiars = result.getParentFile().listFiles(
              new FileFilter() {
                public boolean accept(File pathname) {
                  return pathname.isDirectory()
                      && pathname.getName()
                          .equalsIgnoreCase(
                              directoryName);
View Full Code Here

                dirExists = false;
            }
        }

        // Creating a filter that catches directories.
        FileFilter dirFilter = new FileFilter() {
            public boolean accept(File f) {
                return f.isDirectory();
            }
        };

        assertNull("listFiles Should Return Null.", baseDir
                .listFiles(dirFilter));

        assertTrue("Failed To Create Parent Directory.", baseDir.mkdir());

        FileWrapper dir1 = null;
        String[] files = { "1.tst", "2.tst", "3.tst" };
        try {
            assertEquals("listFiles Should Return An Array Of Length 0.", 0,
                    baseDir.listFiles(dirFilter).length);

            FileWrapper file = new FileWrapperImpl(baseDir, "notADir.tst");
            try {
                FileOutputStream fos = new FileOutputStream(file.getAbsolutePath());
                fos.close();
                assertNull(
                        "listFiles Should Have Returned Null When Used On A File Instead Of A Directory.",
                        file.listFiles(dirFilter));
            } finally {
                file.delete();
            }

            for (int i = 0; i < files.length; i++) {
                FileWrapper f = new FileWrapperImpl(baseDir, files[i]);
                FileOutputStream fos = new FileOutputStream(f.getAbsolutePath());
                fos.close();
            }
            dir1 = new FileWrapperImpl(baseDir, "Temp1");
            dir1.mkdir();

            // Creating a filter that catches files.
            FileFilter fileFilter = new FileFilter() {
                public boolean accept(File f) {
                    return f.isFile();
                }
            };
View Full Code Here

    File[] feedFiles = feedFolder.listFiles();
    for (File file : feedFiles) {
      file.delete();
    }

    FileFilter filter = new FileFilter() {
      public boolean accept(File pathname) {
       return pathname.getName().contains("zip");
      }
    };
View Full Code Here

TOP

Related Classes of java.io.FileFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.