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.ZipUtils.java

/**
  * @param dir The dir to list//w w  w. j a  v  a 2 s.  c o  m
  * @param list The list to add the contents of dir to
  * @return The given list, with the contents of dir added
  */
private static ArrayList<String> listAllFilesAndFolders(final File dir, final ArrayList<String> list) {
    File[] files = dir.listFiles();
    if (files != null) {
        for (int i = 0; i < files.length; i++) {
            File currentFile = files[i];
            boolean currentFileIsDir = currentFile.isDirectory();
            if (currentFileIsDir) {
                // Ignore hidden folders
                if (currentFile.isHidden()) {
                    continue;
                }
                if (currentFile.getName().equalsIgnoreCase("CVS")) {
                    continue;
                }
                if (currentFile.getName().equalsIgnoreCase(".svn")) {
                    continue;
                }
                list.add(currentFile.getPath() + "/");
                /*
                 * the closing "/" has to be there to tell the
                 * ZipOutputStream that this is a folder...
                 */
                listAllFilesAndFolders(currentFile, list);
            } else {
                list.add(currentFile.getPath());
            }
        }
    }
    return list;
}

From source file:de.unidue.ltl.evalita.feat.IsName.java

private void init() throws TextClassificationException {
    if (namelist != null) {
        return;//  w w  w. j av a2s . c om
    }
    namelist = new HashSet<String>();

    for (File file : folder.listFiles()) {
        if (file.isHidden()) {
            continue;
        }
        if (file.isDirectory()) {
            throw new TextClassificationException("Did not expect that namelists are stored in subfolders");
        }

        List<String> readLines = null;
        try {
            readLines = FileUtils.readLines(file, "utf-8");
        } catch (IOException e) {
            throw new TextClassificationException(e);
        }
        for (String l : readLines) {
            if (l.startsWith("#")) {
                continue;
            }
            if (lowerCase) {
                l = l.toLowerCase();
            }

            namelist.add(l);
        }
    }
}

From source file:org.apache.tajo.worker.InterDataRetriever.java

@Override
public FileChunk[] handle(ChannelHandlerContext ctx, HttpRequest request) throws IOException {

    int start = request.getUri().indexOf('?');
    if (start < 0) {
        throw new IllegalArgumentException("Wrong request: " + request.getUri());
    }// w  w  w . j  av a 2  s .  c  o m

    String queryStr = request.getUri().substring(start + 1);
    LOG.info("QUERY: " + queryStr);
    String[] queries = queryStr.split("&");

    String qid = null;
    String fn = null;
    String[] kv;
    for (String query : queries) {
        kv = query.split("=");
        if (kv[0].equals("qid")) {
            qid = kv[1];
        } else if (kv[0].equals("fn")) {
            fn = kv[1];
        }
    }

    String baseDir = map.get(qid);
    if (baseDir == null) {
        throw new FileNotFoundException("No such qid: " + qid);
    }

    File file = new File(baseDir + "/" + fn);
    if (file.isHidden() || !file.exists()) {
        throw new FileNotFoundException("No such file: " + baseDir + "/" + file.getName());
    }
    if (!file.isFile()) {
        throw new FileAccessForbiddenException("No such file: " + baseDir + "/" + file.getName());
    }

    return new FileChunk[] { new FileChunk(file, 0, file.length()) };
}

From source file:org.apache.tajo.worker.dataserver.retriever.AdvancedDataRetriever.java

@Override
public FileChunk[] handle(ChannelHandlerContext ctx, HttpRequest request) throws IOException {

    final Map<String, List<String>> params = new QueryStringDecoder(request.getUri()).getParameters();

    if (!params.containsKey("qid")) {
        throw new FileNotFoundException("No such qid: " + params.containsKey("qid"));
    }//from   w w w.j a v a2  s.c om

    if (params.containsKey("sid")) {
        List<FileChunk> chunks = Lists.newArrayList();
        List<String> qids = splitMaps(params.get("qid"));
        for (String qid : qids) {
            String[] ids = qid.split("_");
            ExecutionBlockId suid = TajoIdUtils.createExecutionBlockId(params.get("sid").get(0));
            TaskId quid = new TaskId(suid, Integer.parseInt(ids[0]));
            TaskAttemptId attemptId = new TaskAttemptId(quid, Integer.parseInt(ids[1]));
            RetrieverHandler handler = handlerMap.get(attemptId.toString());
            FileChunk chunk = handler.get(params);
            chunks.add(chunk);
        }
        return chunks.toArray(new FileChunk[chunks.size()]);
    } else {
        RetrieverHandler handler = handlerMap.get(params.get("qid").get(0));
        FileChunk chunk = handler.get(params);
        if (chunk == null) {
            if (params.containsKey("qid")) { // if there is no content corresponding to the query
                return null;
            } else { // if there is no
                throw new FileNotFoundException("No such a file corresponding to " + params.get("qid"));
            }
        }

        File file = chunk.getFile();
        if (file.isHidden() || !file.exists()) {
            throw new FileNotFoundException("No such file: " + file.getAbsolutePath());
        }
        if (!file.isFile()) {
            throw new FileAccessForbiddenException(file.getAbsolutePath() + " is not file");
        }

        return new FileChunk[] { chunk };
    }
}

From source file:io.proleap.vb6.runner.impl.VbParseTestRunnerImpl.java

@Override
public void parseDirectory(final File inputDirectory) throws IOException {
    if (inputDirectory.isDirectory() && !inputDirectory.isHidden()) {
        for (final File inputFile : inputDirectory.listFiles()) {
            if (inputFile.isFile() && !inputFile.isHidden()) {
                parseFile(inputFile);//  w w  w  .ja v a 2s .co  m
            }
        }
    }
}

From source file:nz.ac.otago.psyanlab.common.designer.source.ImportSourceActivity.java

@Override
public FilenameFilter getfilter() {
    return new FilenameFilter() {
        private Pattern mAllowedFilesPattern = Pattern.compile(Source.FILE_ENDINGS, Pattern.CASE_INSENSITIVE);

        @Override/*from w  w  w. j  av  a  2 s.  c o m*/
        public boolean accept(File dir, String filename) {
            File f = new File(dir, filename);
            if (f.isHidden()) {
                return false;
            }
            if (f.isDirectory()) {
                return true;
            }
            return mAllowedFilesPattern.matcher(filename).matches();
        }
    };
}

From source file:org.apache.tajo.pullserver.retriever.AdvancedDataRetriever.java

@Override
public FileChunk[] handle(ChannelHandlerContext ctx, HttpRequest request) throws IOException {

    final Map<String, List<String>> params = new QueryStringDecoder(request.getUri()).parameters();

    if (!params.containsKey("qid")) {
        throw new FileNotFoundException("No such qid: " + params.containsKey("qid"));
    }//from   ww w.  j  a va2s  . com

    if (params.containsKey("sid")) {
        List<FileChunk> chunks = Lists.newArrayList();
        List<String> taskIds = splitMaps(params.get("qid"));
        for (String eachTaskId : taskIds) {
            String[] taskIdSeqTokens = eachTaskId.split("_");
            ExecutionBlockId ebId = TajoIdUtils.createExecutionBlockId(params.get("sid").get(0));
            TaskId quid = new TaskId(ebId, Integer.parseInt(taskIdSeqTokens[0]));

            TaskAttemptId attemptId = new TaskAttemptId(quid, Integer.parseInt(taskIdSeqTokens[1]));

            RetrieverHandler handler = handlerMap.get(attemptId.toString());
            FileChunk chunk = handler.get(params);
            chunks.add(chunk);
        }
        return chunks.toArray(new FileChunk[chunks.size()]);
    } else {
        RetrieverHandler handler = handlerMap.get(params.get("qid").get(0));
        FileChunk chunk = handler.get(params);
        if (chunk == null) {
            if (params.containsKey("qid")) { // if there is no content corresponding to the query
                return null;
            } else { // if there is no
                throw new FileNotFoundException("No such a file corresponding to " + params.get("qid"));
            }
        }

        File file = chunk.getFile();
        if (file.isHidden() || !file.exists()) {
            throw new FileNotFoundException("No such file: " + file.getAbsolutePath());
        }
        if (!file.isFile()) {
            throw new FileAccessForbiddenException(file.getAbsolutePath() + " is not file");
        }

        return new FileChunk[] { chunk };
    }
}

From source file:org.arakhne.afc.ui.android.filechooser.AsyncFileLoader.java

/** Replies if the given file is hidden in the file chooser.
 * //from   ww w.j a va 2 s .  c om
 * @param file
 * @return <code>true</code> if hidden; <code>false</code> otherwise.
 */
@SuppressWarnings("static-method")
protected boolean isHiddenFile(File file) {
    return file.isHidden() || file.getName().equalsIgnoreCase("lost.dir");
}

From source file:com.sms.server.service.parser.NFOParser.java

private File getNFOFile(String path) {
    // Recursively check for nfo file in given directory path
    for (File candidate : new File(path).listFiles()) {
        if (candidate.isFile() && !candidate.isHidden() && candidate.getName().toLowerCase().endsWith("nfo")) {
            return candidate;
        }/*from   ww w . j  av  a 2  s. co m*/
    }

    return null;
}

From source file:de.fu_berlin.inf.dpp.intellij.project.fs.FolderImp.java

@Override
public IResource[] members(int memberFlags) {
    List<IResource> list = new ArrayList<IResource>();

    for (File myFile : getFullPath().toFile().listFiles()) {
        if (myFile.isFile() && !myFile.isHidden() && (memberFlags == NONE || memberFlags == FILE)) {
            list.add(new FileImp(project, myFile));
        }/* ww w .jav a  2  s .c om*/

        if (myFile.isDirectory() && !myFile.isHidden() && (memberFlags == NONE || memberFlags == FOLDER)) {
            list.add(new FolderImp(project, myFile));
        }
    }

    return list.toArray(new IResource[] {});
}