How to identify if a file is hidden Using Java

 Posted On  | Yashwant Chavan 

This tutorial will help you to identify that file is a hidden or not. So lets have look with sample code.

Java .isHidden() method syntax

.isHidden() method is used to test whether the file is a hidden file or not. It is system-dependent, On UNIX systems, a file is considered to be hidden if its name begins with a period character ('.') and on Windows platform , a file is considered to be hidden if it has been marked as hidden file.

  • Returns: It returns true if and only if the file is hidden with respective to underlying operating system platform
  • Throws: It throws SecurityException - If a security manager exists and its checkRead(java.lang.String) method denies read access to the file

Full Example



public class JavaHiddenFileCheck {
    public static void main(String[] args) {
        File file = new File("c://articles/hidden.txt");

        if (file.isHidden()) {
            System.out.println("File is Hidden!!");
        } else {
            System.out.println("File is Not Hidden!!");



Let us compile and execute the above program.

File is Hidden!!

© 2018

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0302 seconds.