Here you can find the source of isHidden(final Path path)
Parameter | Description |
---|---|
path | the file or folder to check if hidden |
Parameter | Description |
---|---|
IOException | if there is an error reading the file/folder |
public static boolean isHidden(final Path path) throws IOException
//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); } }