We can check a file is hidden or not in Java using isHidden() method of File class in Java. This method returns a boolean value – true or false.
public static boolean isHidden(Path path) throws IOException parameters: path – the path to the file to test. throws: IOException – if an I/O error occurs SecurityException – In the case of the default provider, and a security manager is installed, the checkRead method is invoked to check read access to the file. returns: true: if file is hidden false: if file is not hidden
The precise definition of hidden is platform or provider dependent.
UNIX: A file is hidden if its name begins with a period character (‘.’).
Windows: A file is hidden if it is not a directory and the DOS hidden attribute is set.
Depending on the implementation the isHidden() method may require to access the file system to determine if the file is considered hidden.
This article is contributed by Saket Kumar. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Hidden Form Field using Annotation | Java Servlet
- How to find and open the Hidden files in a Directory using Java
- Java.io.File Class in Java
- Java | Renaming a file
- Delete a file using Java
- Java Class File
- File Permissions in Java
- Java | Appending String to a File
- Moving a file from one directory to another using Java
- How to run java class file which is in different directory?
- Writing a CSV file in Java using OpenCSV
- Myth about the file name and class name in Java
- Copying file using FileStreams in Java
- Reading a CSV file in Java using OpenCSV
- Size of file on the Internet using Java
- How to play an Audio file using Java
- File canExecute() method in Java with Examples
- File getParent() method in Java with Examples
- Different ways of Reading a text file in Java
- Java program to merge two files into a third file