Java Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import java.io.File; import java.io.IOException; public class Main { public static void main(String[] args) throws IOException, SecurityException { File file = new File("c:/myfile.txt"); if (file.isHidden()) { System.out.println("The specified file is hidden"); } else { System.out.println("The specified file is not hidden"); } } } |
Java isHidden() method of File class to perform this check. This method returns a boolean value (true or false), if file is hidden then this method returns true otherwise it returns a false value.