Example usage for java.nio.file Files isHidden

List of usage examples for java.nio.file Files isHidden

Introduction

In this page you can find the example usage for java.nio.file Files isHidden.

Prototype

public static boolean isHidden(Path path) throws IOException 

Source Link

Document

Tells whether or not a file is considered hidden.

Usage

From source file:org.ballerinalang.composer.service.workspace.local.LocalFSWorkspace.java

/**
 * {@inheritDoc}//w  w  w .j  ava  2s  . c o m
 */
@Override
public JsonArray listFilesInPath(String path, List<String> extensions) throws IOException {
    Path ioPath = Paths.get(path);
    JsonArray dirs = new JsonArray();
    Iterator<Path> iterator = Files.list(ioPath).iterator();
    while (iterator.hasNext()) {
        Path next = iterator.next();
        if ((Files.isDirectory(next) || Files.isRegularFile(next)) && !Files.isHidden(next)
                && !isWindowsSystemFile(next)) {
            JsonObject jsnObj = getJsonObjForFile(next, true);
            if (Files.isRegularFile(next)) {
                Path fileName = next.getFileName();
                SuffixFileFilter fileFilter = new SuffixFileFilter(extensions, IOCase.INSENSITIVE);
                if (null != fileName && fileFilter.accept(next.toFile())) {
                    dirs.add(jsnObj);
                }
            } else {
                dirs.add(jsnObj);
            }

        }
    }
    return dirs;
}

From source file:org.opendatakit.briefcase.reused.UncheckedFiles.java

private static boolean isHidden(Path path) {
    try {/*from ww  w.  java2  s  .  c  o m*/
        return Files.isHidden(path);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:org.olat.course.assessment.bulk.DataStepForm.java

private void processReturnFiles(VFSLeaf target, List<BulkAssessmentRow> rows) {
    Map<String, BulkAssessmentRow> assessedIdToRow = new HashMap<>();
    for (BulkAssessmentRow row : rows) {
        assessedIdToRow.put(row.getAssessedId(), row);
    }// ww  w  .j av  a 2  s . com

    if (target.exists()) {
        InputStream is = target.getInputStream();
        File parentTarget = ((LocalImpl) target).getBasefile().getParentFile();
        ZipInputStream zis = new ZipInputStream(is);

        ZipEntry entry;
        try {
            byte[] b = new byte[FileUtils.BSIZE];
            while ((entry = zis.getNextEntry()) != null) {
                if (!entry.isDirectory()) {
                    while (zis.read(b) > 0) {
                        //continue
                    }

                    Path op = new File(parentTarget, entry.getName()).toPath();
                    if (!Files.isHidden(op) && !Files.isDirectory(op)) {
                        Path parentDir = op.getParent();
                        String assessedId = parentDir.getFileName().toString();
                        String filename = op.getFileName().toString();

                        BulkAssessmentRow row;
                        if (assessedIdToRow.containsKey(assessedId)) {
                            row = assessedIdToRow.get(assessedId);
                        } else {
                            row = new BulkAssessmentRow();
                            row.setAssessedId(assessedId);
                            assessedIdToRow.put(assessedId, row);
                            rows.add(row);
                        }

                        if (row.getReturnFiles() == null) {
                            row.setReturnFiles(new ArrayList<String>(2));
                        }
                        row.getReturnFiles().add(filename);
                    }
                }
            }
        } catch (Exception e) {
            logError("", e);
        } finally {
            IOUtils.closeQuietly(is);
            IOUtils.closeQuietly(zis);
        }
    }
}

From source file:org.niord.core.batch.BatchService.java

/** Returns the list of regular files in the given directory **/
private List<Path> getDirectoryFiles(Path dir) {
    List<Path> files = new ArrayList<>();
    try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
        for (Path p : stream) {
            if (Files.isReadable(p) && Files.isRegularFile(p) && !Files.isHidden(p)) {
                files.add(p);// www  .  jav a 2s . c  o m
            }
        }
    } catch (IOException ignored) {
    }
    return files;
}