Example usage for java.io File isHidden

List of usage examples for java.io File isHidden

Introduction

In this page you can find the example usage for java.io File isHidden.

Prototype

public boolean isHidden() 

Source Link

Document

Tests whether the file named by this abstract pathname is a hidden file.

Usage

From source file:eu.planets_project.services.utils.test.FileAccess.java

private static void index(File root, Map<String, File> map) {
    String[] list = root.list();/*w w w.  j  a va 2  s .  co  m*/
    for (String name : list) {
        File f = new File(root, name);
        if (f.isDirectory() && !f.isHidden()) {
            index(f, map);
        } else if (f.isFile() && !f.isHidden()) {
            map.put(FilenameUtils.getExtension(f.getName()).toLowerCase(), f);
        }
    }
}

From source file:it.serasoft.pdi.PDITools.java

private static void getFilesList(File f, ArrayList<File> completeFilesList, boolean recurse) {

    File[] files = f.listFiles();
    for (File item : files) {
        if (recurse && item.isDirectory() && !item.isHidden()) {
            getFilesList(item, completeFilesList, recurse);
        } else if (item.isFile() && !item.isHidden()
                && (item.getName().endsWith(EXT_PDI_JOB) || item.getName().endsWith(EXT_PDI_TRANSFORMATION))) {
            completeFilesList.add(item);
        }/*from  w w w .j  a va 2  s .c  om*/
    }
}

From source file:org.beangle.commons.text.replacer.BatchReplaceMain.java

public static void replaceFile(String fileName, final Map<String, List<Replacer>> profiles, String encoding)
        throws Exception, FileNotFoundException {
    File file = new File(fileName);
    if (file.isFile() && !file.isHidden()) {
        List<Replacer> replacers = profiles.get(StringUtils.substringAfterLast(fileName, "."));
        if (null == replacers) {
            return;
        }/*from  ww w. j  ava 2s.  co  m*/
        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);
                    if (matched)
                        return true;
                }
                return false;
            }
        });
        if (null != subFiles) {
            for (int i = 0; i < subFiles.length; i++) {
                replaceFile(fileName + '/' + subFiles[i], profiles, encoding);
            }
        }
    }
}

From source file:Main.java

/**
 * @param file/*  www  .j av  a  2s .  co m*/
 * @param includeHiddleFiles
 * @param includeFolder
 * @return
 */
private static int getSubfilesNumberInFolder(File file, boolean includeHiddleFiles, boolean includeFolder) {
    int size = 0;
    File[] files = file.listFiles();
    if (files != null) {
        for (int i = 0; i < files.length; i++) {
            File file2 = files[i];
            if (!includeHiddleFiles && file2.isHidden()) {
                continue;
            }
            if (file2.isDirectory()) {
                size += getSubfilesNumberInFolder(file2, includeHiddleFiles, includeFolder);
            } else {
                size += 1;
            }
        }
    }
    if (includeFolder) {
        size++;
    }
    return size;
}

From source file:net.landora.video.info.file.FileHasher.java

public static void checkDirectory(File dir) throws IOException {
    for (File file : dir.listFiles()) {
        if (file.isHidden()) {
            continue;
        }/*from  w  w  w.j a v a 2s .  c om*/

        if (file.isDirectory()) {
            checkDirectory(file);
        } else {

            String extension = ExtensionUtils.getExtension(file);
            if (!ExtensionUtils.isVideoExtension(extension)) {
                continue;
            }

            FileInfo info = FileInfoManager.getInstance().getFileInfo(file);
            VideoMetadata md = MetadataProvidersManager.getInstance().getMetadata(info);

            if (md == null) {
                continue;
            }

            file = file.getCanonicalFile();

            String filename = getOutputFilename(md) + "." + extension;

            File outputFile = new File(getOutputFolder(md), filename);
            outputFile.getParentFile().mkdirs();
            outputFile = outputFile.getCanonicalFile();

            if (!outputFile.equals(file)) {
                if (outputFile.exists()) {
                } else {
                    FileUtils.moveFile(file, outputFile);
                }

            }

        }
    }
}

From source file:eu.annocultor.reports.ReportPresenter.java

public static void generateReport(File annoCultorHome) throws Exception {
    Logger log = LoggerFactory.getLogger("ReportPresenter");
    File dir = new File(annoCultorHome, "doc");
    if (dir.isDirectory() && dir.exists() && dir.list().length > 0) {

        for (File fn : dir.listFiles()) {
            if (fn.isDirectory() && !fn.isHidden()) {
                String datasetId = fn.getName();
                log.info("Loading conversion statistics for " + datasetId);
                ReportPresenter reportPresenter = new ReportPresenter(dir, datasetId);
                log.info("Generating conversion report for " + datasetId);
                reportPresenter.makeHtmlReport();
            }/*  w ww  . jav  a 2 s  .co  m*/
        }
    }
}

From source file:Main.java

public static File[] getMountedVolumesAsFile() {
    final String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { // we can read the External Storage...           
        //Retrieve the primary External Storage:
        final File primaryExternalStorage = Environment.getExternalStorageDirectory();

        //Retrieve the External Storages root directory:
        String externalStorageRootDir = null;
        if ((externalStorageRootDir = primaryExternalStorage.getParent()) == null) { // no parent...
            return (new File[] { primaryExternalStorage });
        } else {/* w  w w  . j a v a2s . c o m*/
            final File externalStorageRoot = new File(externalStorageRootDir);
            final File[] files = externalStorageRoot.listFiles(new FilenameFilter() {

                @Override
                public boolean accept(File dir, String filename) {
                    // TODO Auto-generated method stub

                    File file = new File(dir, filename);
                    if (file.isDirectory() && file.canRead() && file.canWrite() && !file.isHidden()) {
                        return true;
                    }
                    return false;
                }

            }); //.listFiles();
            List<File> data = new ArrayList<File>();

            for (final File file : files) {
                if (file.isDirectory() && file.canRead() && file.canWrite() && !file.isHidden()
                        && (files.length > 0)) { // it is a real directory (not a USB drive)...
                    if (file.toString().equals(primaryExternalStorage.toString()))
                        data.add(file);
                    else {
                        if (!file.toString().contains("usb") || !file.toString().contains("USB")) {
                            data.add(file);
                        }
                    }
                }
            }
            return data.toArray(new File[data.size()]);
        }
    } else {
        // we cannot read the External Storage..., return null
        return null;
    }
}

From source file:com.khubla.antlr4formatter.Antlr4Formatter.java

/**
 * get a list of all files in a directory
 *//* w  w w . j a  v a  2  s.com*/
private static List<String> getFiles(String dir, List<String> files, String filter) throws Exception {
    final File file = new File(dir);
    final String[] list = file.list();
    if (null != list) {
        for (int i = 0; i < list.length; i++) {
            final String fileName = dir + (dir.endsWith("/") ? "" : "/") + list[i];
            final File f2 = new File(fileName);
            if (false == f2.isHidden()) {
                if (f2.isDirectory()) {
                    getFiles(fileName + "/", files, filter);
                } else {
                    if (fileName.endsWith(filter)) {
                        files.add(fileName);
                    }
                }
            }
        }
    }
    return files;
}

From source file:Main.java

public static String[] getMountedVolumes() {
    final String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { // we can read the External Storage...           
        //Retrieve the primary External Storage:
        final File primaryExternalStorage = Environment.getExternalStorageDirectory();

        //Retrieve the External Storages root directory:
        String externalStorageRootDir = null;
        if ((externalStorageRootDir = primaryExternalStorage.getParent()) == null) { // no parent...
            return (new String[] { "ONLY A SINGLE VOLUME HAS BEEN DETECTED!",
                    (Environment.isExternalStorageRemovable() ? "(REMOVABLE SD-CARD)" : "(INTERNAL STORAGE)")
                            + " PRIMARY STORAGE: " + primaryExternalStorage });
        } else {/*from w  ww .jav  a2  s.c  om*/
            final File externalStorageRoot = new File(externalStorageRootDir);
            final File[] files = externalStorageRoot.listFiles(new FilenameFilter() {

                @Override
                public boolean accept(File dir, String filename) {
                    // TODO Auto-generated method stub

                    File file = new File(dir, filename);
                    if (file.isDirectory() && file.canRead() && file.canWrite() && !file.isHidden()) {
                        return true;
                    }
                    return false;
                }

            }); //.listFiles();
            List<String> data = new ArrayList<String>();
            if (files.length > 1) {
                data.add("MULTIPLE VOLUMES HAS BEEN DETECTED!");
                data.add("Enumerating detected volumes . . .");
            } else {
                data.add("ONLY A SINGLE VOLUME HAS BEEN DETECTED!");
            }

            for (final File file : files) {
                if (file.isDirectory() && file.canRead() && file.canWrite() && !file.isHidden()
                        && (files.length > 0)) { // it is a real directory (not a USB drive)...
                    if (file.toString().equals(primaryExternalStorage.toString()))
                        data.add((Environment.isExternalStorageRemovable() ? "(REMOVABLE SD-CARD)"
                                : "(INTERNAL Memory)") + " PRIMARY STORAGE: " + file.getAbsolutePath());
                    else {
                        data.add(((file.toString().contains("usb") || file.toString().contains("USB"))
                                ? "MOUNTED USB"
                                : "MOUNTED") + " STORAGE: " + file.getAbsolutePath());
                    }
                }
            }
            return data.toArray(new String[data.size()]);
        }
    } else {
        // we cannot read the External Storage..., return null
        return null;
    }

}

From source file:org.icefaces.ace.util.cssurlmapper.Main.java

public static void processDirectory(File dir, String libraryName, File referenceDir, File outputDir) {
    try {// w ww  .ja va2 s . com
        System.out.println("Entering directory " + dir.getCanonicalPath());
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }

    File[] children = dir.listFiles();
    for (int i = 0; i < children.length; i++) {
        try {
            File file = children[i];
            if (file.isHidden()) { // do not process hidden files and directories
                continue;
            }
            if (file.isDirectory()) {
                File newOutputDir = new File(outputDir, file.getName());
                newOutputDir.mkdir();
                processDirectory(file, libraryName, referenceDir, newOutputDir);
            } else if (file.isFile()) {
                String path = file.getCanonicalPath();
                if (path.length() > 4 && path.substring(path.length() - 4).equalsIgnoreCase(".css")) {
                    processFile(file, libraryName, referenceDir, outputDir);
                }
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }

    try {
        System.out.println("Leaving directory " + dir.getCanonicalPath());
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}