On this document we will be showing a java example on how to use the isHidden() method of File Class. This method tests whether the file named by this abstract pathname is a hidden file. The exact definition of hidden is system-dependent. On UNIX systems, a file is considered to be hidden if its name begins with a period character (‘.’). On Microsoft Windows systems, a file is considered to be hidden if it has been marked as such in the filesystem.


SecurityException – If a security manager exists and its SecurityManager.checkRead(java.lang.String) method denies read access to the file

Method Syntax

public boolean isHidden()

Method Argument

Data Type Parameter Description

Method Returns

This method returns a boolean, true if and only if the file denoted by this abstract pathname is hidden according to the conventions of the underlying platform.


Requires Java 1.0 and up

Java File isHidden() Example

Below is a java code demonstrates the use of isHidden() method of File class. The example presented might be simple however it shows the behaviour of the isHidden() method of File class. We put a check if the file is hidden or not using isHidden() method, the result is evaluated and messages are printed based on it.



 * This example source code demonstrates the use of  
 * isHidden() method of File class.

public class FileIsHiddenExample {

	public static void main(String[] args) {

		// initialize File object
		File file = new File("C:javatutorialhqinputtest_file.txt");
		// check if the file is hidden
		boolean result = file.isHidden();
		if (result) {
			System.out.println(file.getAbsolutePath()+ " is hidden");
			System.out.println(file.getAbsolutePath()+ " is not hidden");


Sample Output

Below is the sample output when you run the above example.

java lang File isHidden() example output