The File.isHidded()
method checks to see if the file represented by aFile
object is a hidden file. The definition of hidden is varied between operating systems. On UNIX based systems, a file is considered to be hidden when their name begins with a period character ('.'
). On Windows operating system, a file is considered to be hidden if it has been marked hidden in the filesystem.
This File.isHidden()
method returns true
if and only if the file denoted by this File
object is hidden according to the conventions of the underlying platform.
package org.kodejava.io;
import java.io.File;
import java.io.IOException;
public class FileHiddenExample {
public static void main(String[] args) throws IOException {
File file = new File("Hidden.txt");
file.createNewFile();
// We are using the isHidden() method to check whether a file
// is hidden.
if (file.isHidden()) {
System.out.println("File is hidden!");
} else {
System.out.println("File is not hidden!");
}
}
}
If you want to set the file attribute to hidden in Windows operating system you can see it in the following example: How do I set the value of file attributes?
Latest posts by Wayan (see all)
- How do I create a string of repeated characters? - September 1, 2023
- How do I convert datetime string with optional part to a date object? - August 28, 2023
- How do I split large excel file into multiple smaller files? - April 15, 2023