Following example demonstrates how to get the fact that a file is hidden or not by using file.isHidden() method of File class.
import java.io.File;
public class Main {
public static void main(String[] args) {
File file = new File("C:/Demo.txt");
System.out.println(file.isHidden());
}
}
Result:
The above code sample will produce the following result (as Demo.txt is hidden).