Package java.io

Examples of java.io.FilenameFilter


                dirExists = false;
            }
        }

        // Creating a filter that catches "*.tst" files.
        FilenameFilter tstFilter = new FilenameFilter() {
            public boolean accept(File f, String fileName) {
                return fileName.endsWith(".tst");
            }
        };

        assertNull("listFiles Should Return Null.", dir.listFiles(tstFilter));

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

        String[] files = { "1.tst", "2.tst", "3.tmp" };
        try {
            assertEquals("listFiles Should Return An Array Of Length 0.", 0,
                    dir.listFiles(tstFilter).length);

            FileWrapper file = new FileWrapperImpl(dir, "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(tstFilter));
            } finally {
                file.delete();
            }

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

            // Creating a filter that catches "*.tmp" files.
            FilenameFilter tmpFilter = new FilenameFilter() {
                public boolean accept(File f, String fileName) {
                    // If the suffix is ".tmp" then send it to the array
                    if (fileName.endsWith(".tmp")) {
                        return true;
                    } else {
View Full Code Here


            } else {
                dirExists = false;
            }
        }

        FilenameFilter filter = new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return !name.equals("mtzz1.xx");
            }
        };
View Full Code Here

      logger.info("processing {}", fileName);
      String filecontent = FileUtils.readFileToString(file, encoding);
      filecontent = Replacer.process(filecontent, replacers);
      writeToFile(filecontent, fileName, encoding);
    } else {
      String[] subFiles = file.list(new FilenameFilter() {
        public boolean accept(File dir, String name) {
          if (dir.isDirectory()) return true;
          boolean matched = false;
          for (String key : profiles.keySet()) {
            matched = name.endsWith(key);
View Full Code Here

  private void init() throws SldException {
    if (getDirectory() != null) {
      try {
        if (getDirectory().getFile().exists()) {
          if (getDirectory().getFile().isDirectory()) {
            File[] sldFiles = getDirectory().getFile().listFiles(new FilenameFilter() {

              public boolean accept(File dir, String name) {
                return name.endsWith(".sld") || name.endsWith(".xml");
              }
            });
View Full Code Here

        String filenameToLookFor = Util.expandBrackets(filePart, entry, database)
                .replaceAll(EXT_MARKER, extensionRegExp);
        final Pattern toMatch = Pattern.compile("^"
            + filenameToLookFor.replaceAll("\\\\\\\\", "\\\\") + "$", Pattern.CASE_INSENSITIVE);

        File[] matches = directory.listFiles(new FilenameFilter() {
            public boolean accept(File arg0, String arg1) {
                return toMatch.matcher(arg1).matches();
            }
        });
        if (matches != null && (matches.length > 0))
View Full Code Here

    public boolean hasEntry(String name) {
      return new File(basedir, name).exists();
    }

    public String[] listEntries() {
       return basedir.list(new FilenameFilter() {
      public boolean accept(File f, String name) {
        return !new File(f, name).isDirectory();
      }
       });
    }
View Full Code Here

    Collections.sort(extensionBundlesList);
  }

  private void loadDir(File dir) throws ExtensionException {
    if (dir.isDirectory()) {
      File[] descriptors = dir.listFiles(new FilenameFilter() {
        public boolean accept(File f, String filename) {
          return filename.equals("application.xml") || filename.equals("extension.xml");
        }
      });
View Full Code Here

        parent.mkdirs();
       
        try {
            ZipExtract.extractZipFile(parent, new FileInputStream(file));
           
            String[] certs = parent.list(new FilenameFilter() {
              public boolean accept(File file, String filename) {
                return filename.endsWith(".crt") && (!filename.equals(actualCert) && !filename.equals(actualCert.replaceAll("\\*", "STAR")));
              }
            });
            String pw = Property.getProperty(new ContextKey("webServer.keystore.sslCertificate.password"));
View Full Code Here

        allFiles.add(fileNames[i]);
      } else {
        String prefix = fileNames[i].substring(0, k);
        if (prefix.length() == 0) prefix = ".";
        final String suffix = fileNames[i].substring(k+1);
        File[] files = new File(prefix).listFiles(new FilenameFilter() {
          public boolean accept(File dir, String name) {
            return name.endsWith(suffix);
          }
        });
        if (files != null) {
View Full Code Here

    public FontRecord[] getFontRecords() {
        String javaHome = System.getProperty("java.home");
        File fontDirectory = new File(javaHome + "/lib/fonts");
        // TTFReader ttfReader = new TTFReader();
        File[] children = fontDirectory.listFiles(new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return name.toLowerCase().endsWith(".ttf");
            }
        });
        if (children == null) {
View Full Code Here

TOP

Related Classes of java.io.FilenameFilter

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.