Java File isHidden() method example

HQ ┬╗ Java Tutorial ┬╗ ┬╗ File ┬╗ isHidden() method example
Java File isHidden() method example 2018-02-16T07:26:42+00:00 isHidden()


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.

Sample Output

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

java lang File isHidden() example output

Contact Info


Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.