Java Path File Check nio isHidden(final Path path)

Here you can find the source of isHidden(final Path path)

Description

Due to the way that windows handles hidden files vs.

License

Open Source License

Parameter

Parameter Description
path the file or folder to check if hidden

Exception

Parameter Description
IOException if there is an error reading the file/folder

Return

if the file or folder is hidden

Declaration

public static boolean isHidden(final Path path) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.DosFileAttributes;

public class Main {
    /**/*from   ww w . j av  a2  s . com*/
     * Due to the way that windows handles hidden files vs. *nix 
     * we use this method to determine if a file or folder is really hidden
     * @param path the file or folder to check if hidden
     * @return if the file or folder is hidden
     * @throws IOException if there is an error reading the file/folder
     */
    public static boolean isHidden(final Path path) throws IOException {
        //cause Files.isHidden() doesn't work properly for windows...
        if (System.getProperty("os.name").contains("Windows")) {
            return Files.readAttributes(path, DosFileAttributes.class).isHidden();
        }

        return Files.isHidden(path);
    }
}

Related

  1. isFile(Path file)
  2. isFileHidden(Path file)
  3. isFileSymLink(File path)
  4. isFileWritable(final Path file)
  5. isFolder(Path path)
  6. isHidden(Path path)
  7. isHidden(Path path)
  8. isHidden(Path value)
  9. isJniNativeFunction(Path path)