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:jp.massbank.spectrumsearch.logic.MassBankRecordLogic.java

public static int getFilesCount(File file) {
    int count = 0;
    if (!file.getName().equals(SystemProperties.getInstance().getDatabaseName())) {
        File[] files = file.listFiles();
        for (File f : files) {
            if (!f.isHidden()) {
                if (f.isDirectory()) {
                    count += getFilesCount(f);
                } else {
                    count++;//from   w  w  w.  ja v a 2s . c  o m
                }
            }
        }
    }
    return count;
}

From source file:org.sakaiproject.portal.charon.test.PortalTestFileUtils.java

/**
 * @param parentFile//from   ww  w . ja  v  a  2s . c  o  m
 * @throws IOException
 */
public static void listDirectory(File f) throws IOException {
    recurseGrouped(f, new RecurseAction() {

        long total = 0;

        public void doFile(File file) throws IOException {
            if (!file.isDirectory()) {
                listFile(file);
                total += file.length();
            }

        }

        private void listFile(File file) {
            char[] c = new char[4];
            c[0] = '-';
            c[0] = file.isDirectory() ? 'd' : c[0];
            c[0] = file.isFile() ? 'f' : c[0];
            c[1] = file.isHidden() ? 'h' : '-';
            c[2] = file.canRead() ? 'r' : '-';
            c[3] = file.canWrite() ? 'w' : '-';
            log.info(new String(c) + "  " + getSizeStr(file.length()) + " " + file.getName());

        }

        private String getSizeStr(long size) {
            String sizeStr = String.valueOf(size) + "B";
            if (size > (1024L * 1024L * 1024L * 10L)) {
                sizeStr = String.valueOf(size / (1024L * 1024L * 1024L)) + "G";
            } else if (size > (1024L * 1024L * 10L)) {
                sizeStr = String.valueOf(size / (1024L * 1024L)) + "M";
            } else if (size > (1024L * 10L)) {
                sizeStr = String.valueOf(size / (1024L)) + "K";
            }
            return sizeStr;

        }

        public void doBeforeFile(File f) {
            if (f.isDirectory()) {
                char[] c = new char[4];
                c[0] = '-';
                c[0] = f.isDirectory() ? 'd' : c[0];
                c[0] = f.isFile() ? 'f' : c[0];
                c[1] = f.isHidden() ? 'h' : '-';
                c[2] = f.canRead() ? 'r' : '-';
                c[3] = f.canWrite() ? 'w' : '-';
                log.info(new String(c) + "  " + f.getAbsolutePath());
                log.info("--------------------------------------------------------");
            }
        }

        public void doAfterFile(File f) {
            if (f.isDirectory()) {
                log.info("Total :" + getSizeStr(total) + " " + f.getAbsolutePath());
                log.info("--------------------------------------------------------");
                total = 0;
            } else {
                log.info("Not A Directory " + f.getAbsolutePath());
            }

        }

    });
    // TODO Auto-generated method stub

}

From source file:com.amaze.carbonfilemanager.filesystem.RootHelper.java

/**
 * Loads files in a path using basic filesystem callbacks
 *
 * @param path       the path// w ww.j a  v  a 2 s . c  om
 * @param showHidden
 * @return
 */
public static ArrayList<BaseFile> getFilesList(String path, boolean showHidden) {
    File f = new File(path);
    ArrayList<BaseFile> files = new ArrayList<>();
    try {
        if (f.exists() && f.isDirectory()) {
            for (File x : f.listFiles()) {
                long size = 0;
                if (!x.isDirectory())
                    size = x.length();
                BaseFile baseFile = new BaseFile(x.getPath(), parseFilePermission(x), x.lastModified(), size,
                        x.isDirectory());
                baseFile.setName(x.getName());
                baseFile.setMode(OpenMode.FILE);
                if (showHidden) {
                    files.add(baseFile);
                } else {
                    if (!x.isHidden()) {
                        files.add(baseFile);
                    }
                }
            }
        }
    } catch (Exception e) {
    }
    return files;
}

From source file:com.amaze.filemanager.filesystem.RootHelper.java

/**
 * Loads files in a path using basic filesystem callbacks
 *
 * @param path       the path/*  w w  w .  j  av  a2s.  co m*/
 */
public static ArrayList<HybridFileParcelable> getFilesList(String path, boolean showHidden,
        OnFileFound listener) {
    File f = new File(path);
    ArrayList<HybridFileParcelable> files = new ArrayList<>();
    try {
        if (f.exists() && f.isDirectory()) {
            for (File x : f.listFiles()) {
                long size = 0;
                if (!x.isDirectory())
                    size = x.length();
                HybridFileParcelable baseFile = new HybridFileParcelable(x.getPath(), parseFilePermission(x),
                        x.lastModified(), size, x.isDirectory());
                baseFile.setName(x.getName());
                baseFile.setMode(OpenMode.FILE);
                if (showHidden) {
                    files.add(baseFile);
                    listener.onFileFound(baseFile);
                } else {
                    if (!x.isHidden()) {
                        files.add(baseFile);
                        listener.onFileFound(baseFile);
                    }
                }
            }
        }
    } catch (Exception e) {
    }
    return files;
}

From source file:org.lnicholls.galleon.gui.Galleon.java

private static void createAndShowGUI() {
    try {/*from   w  w  w . ja va 2s  .  co  m*/
        System.setProperty("os.user.home", System.getProperty("user.home"));

        ArrayList errors = new ArrayList();
        Server.setup(errors);
        log = Server.setupLog("org.lnicholls.galleon.gui.Galleon", "GuiTrace", "GuiFile",
                Constants.GUI_LOG_FILE);
        // log = Logger.getLogger(Galleon.class.getName());
        printSystemProperties();

        UIManager.put("ClassLoader", (com.jgoodies.plaf.LookUtils.class).getClassLoader());
        UIManager.put("Application.useSystemFontSettings", Boolean.TRUE);
        Options.setGlobalFontSizeHints(FontSizeHints.MIXED2);
        Options.setDefaultIconSize(new Dimension(18, 18));
        try {
            UIManager.setLookAndFeel(
                    LookUtils.IS_OS_WINDOWS_XP ? "com.jgoodies.plaf.plastic.PlasticXPLookAndFeel"
                            : Options.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            Tools.logException(Galleon.class, e);
        }

        /*
         * mServerConfiguration = new ServerConfiguration(); if
         * (mConfigureDir != null) { log.info("Configuration Dir=" +
         * mConfigureDir.getAbsolutePath()); new
         * Configurator(mServerConfiguration).load(mAppManager,
         * mConfigureDir); } else new
         * Configurator(mServerConfiguration).load(mAppManager); mAddress =
         * mServerConfiguration.getIPAddress(); if (mAddress == null ||
         * mAddress.length() == 0) mAddress = "127.0.0.1";
         */
        log.info("Server address: " + mServerAddress);
        for (int i = 0; i < 100; i++) {
            try {
                mRegistry = LocateRegistry.getRegistry(mServerAddress, 1099 + i);
                String[] names = mRegistry.list();
                ServerControl serverControl = (ServerControl) mRegistry.lookup("serverControl");
                log.info("Found server at: " + mServerAddress + " on " + (1099 + i));
                break;
            } catch (Throwable ex) {
                if (log.isDebugEnabled())
                    Tools.logException(Galleon.class, ex);
            }
        }

        File directory = new File(System.getProperty("apps"));
        if (!directory.exists() || !directory.isDirectory()) {
            String message = "App Class Loader directory not found: " + System.getProperty("apps");
            InstantiationException exception = new InstantiationException(message);
            log.error(message, exception);
            throw exception;
        }

        File[] files = directory.listFiles(new FileFilter() {
            public final boolean accept(File file) {
                return !file.isDirectory() && !file.isHidden() && file.getName().toLowerCase().endsWith(".jar");
            }
        });
        ArrayList urls = new ArrayList();
        for (int i = 0; i < files.length; ++i) {
            try {
                URL url = files[i].toURI().toURL();
                urls.add(url);
                log.debug(url);
            } catch (Exception ex) {
                // should never happen
            }
        }

        directory = new File(System.getProperty("hme"));
        if (directory.exists()) {
            files = directory.listFiles(new FileFilter() {
                public final boolean accept(File file) {
                    return !file.isDirectory() && !file.isHidden()
                            && file.getName().toLowerCase().endsWith(".jar");
                }
            });
            for (int i = 0; i < files.length; ++i) {
                try {
                    URL url = files[i].toURI().toURL();
                    urls.add(url);
                    log.debug(url);
                } catch (Exception ex) {
                    // should never happen
                }
            }
        }

        File currentDirectory = new File(".");
        directory = new File(currentDirectory.getAbsolutePath() + "/../lib");
        // TODO Handle reloading; what if list changes?
        files = directory.listFiles(new FileFilter() {
            public final boolean accept(File file) {
                return !file.isDirectory() && !file.isHidden() && file.getName().toLowerCase().endsWith(".jar");
            }
        });
        for (int i = 0; i < files.length; ++i) {
            try {
                URL url = files[i].toURI().toURL();
                urls.add(url);
                log.debug(url);
            } catch (Exception ex) {
                // should never happen
            }
        }

        URLClassLoader classLoader = new URLClassLoader((URL[]) urls.toArray(new URL[0]));
        Thread.currentThread().setContextClassLoader(classLoader);

        mMainFrame = new MainFrame(Tools.getVersion());

        splashWindow.setVisible(false);
        mMainFrame.setVisible(true);

        /*
         * javax.swing.SwingUtilities.invokeLater(new Runnable() { public
         * void run() { mToGo.getRecordings(); } });
         */

        if (!isCurrentVersion()) {
            if (JOptionPane.showConfirmDialog(mMainFrame,
                    "A new version of Galleon is available. Do you want to download the latest version?",
                    "New Version", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                try {
                    BrowserLauncher.openURL("http://galleon.tv");
                } catch (Exception ex) {
                    Tools.logException(Galleon.class, ex);
                }
            }
        }

    } catch (Exception ex) {
        Tools.logException(Galleon.class, ex);
        System.exit(0);
    }
}

From source file:com.github.maven_nar.NarUtil.java

public static void runRanlib(final File file, final Log log)
        throws MojoExecutionException, MojoFailureException {
    if (!file.exists()) {
        return;//from   ww w.j  a  va2  s.c  o m
    }

    if (file.isDirectory()) {
        final File[] files = file.listFiles();
        for (final File file2 : files) {
            runRanlib(file2, log);
        }
    }
    if (file.isFile() && file.canWrite() && !file.isHidden() && file.getName().endsWith(".a")) {
        // ranlib file
        final int result = runCommand("ranlib", new String[] { file.getPath() }, null, null, log);
        if (result != 0) {
            throw new MojoExecutionException(
                    "Failed to execute 'ranlib " + file.getPath() + "'" + " return code: \'" + result + "\'.");
        }
    }
}

From source file:de.u808.simpleinquest.util.DirectoryTraverser.java

private void processFile(File file) {
    if (!file.isHidden()) {
        if (file.isDirectory()) {
            if (traversalMode.equals(TraversalMode.FilesAndDirectories)
                    || traversalMode.equals(TraversalMode.JustDirectories)) {
                this.fileProcessor.processFile(file);
            }//from w ww . j  ava 2 s  .  c  o  m
            if (!file.equals(this.rootDir)) {
                processRootDirectory(file);
            }
        } else if (traversalMode.equals(TraversalMode.JustFiles)
                || traversalMode.equals(TraversalMode.FilesAndDirectories)) {
            this.fileProcessor.processFile(file);
        }
    } else {
        log.info("Ignoring hidden file: " + file.getPath());
    }
}

From source file:com.github.maven_nar.NarUtil.java

public static void makeExecutable(final File file, final Log log)
        throws MojoExecutionException, MojoFailureException {
    if (!file.exists()) {
        return;//from   www  .  j  ava 2  s.c o m
    }

    if (file.isDirectory()) {
        final File[] files = file.listFiles();
        for (final File file2 : files) {
            makeExecutable(file2, log);
        }
    }
    if (file.isFile() && file.canRead() && file.canWrite() && !file.isHidden()) {
        // chmod +x file
        final int result = runCommand("chmod", new String[] { "+x", file.getPath() }, null, null, log);
        if (result != 0) {
            throw new MojoExecutionException("Failed to execute 'chmod +x " + file.getPath() + "'"
                    + " return code: \'" + result + "\'.");
        }
    }
}

From source file:com.github.maven_nar.NarUtil.java

public static void makeLink(final File file, final Log log)
        throws MojoExecutionException, MojoFailureException {
    if (!file.exists()) {
        return;/*  w  w  w .  ja v a  2 s.  c  o  m*/
    }

    if (file.isDirectory()) {
        final File[] files = file.listFiles();
        for (final File file2 : files) {
            makeLink(file2, log);
        }
    }
    if (file.isFile() && file.canRead() && file.canWrite() && !file.isHidden()
            && file.getName().matches(".*\\.so(\\.\\d+)+$")) {
        final File sofile = new File(file.getParent(),
                file.getName().substring(0, file.getName().indexOf(".so") + 3));
        if (!sofile.exists()) {
            // ln -s lib.so.xx lib.so
            final int result = runCommand("ln", new String[] { "-s", file.getName(), sofile.getPath() }, null,
                    null, log);
            if (result != 0) {
                throw new MojoExecutionException("Failed to execute 'ln -s " + file.getName() + " "
                        + sofile.getPath() + "'" + " return code: \'" + result + "\'.");
            }
        }
    }
}

From source file:com.tcl.lzhang1.mymusic.MusicUtil.java

/**
 * scan file by file//w  ww .  j av a 2  s. co  m
 * 
 * @param file
 */
public static void scanFile(File file) {
    if (file == null) {
        return;
    }

    if (!file.isHidden()) {

        if (file.isFile()) {
            // do something
            if (!isMusic(file)) {
                return;
            }

            SongModel model = getMusicInfo(file.getAbsolutePath());
            if (null != mScanListener) {
                Log.i(LOG_TAG, "music file:" + file.getName());
                mScanListener.onMusicScaned(model);
            }
        } else if (file.isDirectory()) {
            File[] files = file.listFiles();
            if (null != files && files.length != 0) {

                for (File file2 : files) {
                    scanFile(file2);
                }
            }
        }
    } else {

        return;

    }
}