In this example we will show the method to check if a file is hidden in Java.
Source Code
package com.beginner.examples;
import java.io.*;
public class FileHidden {
public static void main(String[] args) {
File f = new File("example.txt");
if (f.isHidden()) { // check if a file is hidden
System.out.println("The file is hidden.");
} else {
System.out.println("The file is not hidden!");
}
}
}
Output:
The file is not hidden!