Home » Java programs » Java file handling programs

Java program to check whether a file is hidden or not

In this java program, we are going to learn, how to check whether a file is hidden or not? Method isHidden() of "File" class is used to check it.
Submitted by IncludeHelp, on October 27, 2017

Given a file, and we have to check whether it is hidden or not using Java program?

File. isHidden()

This is a method of "File" class, which returns true if a file has hidden property and return false if it is not.

In this program, we are using a file named "includehelp.txt" which is stored in "E:\" in my system, program will check its hidden property and returns the result.

Program to check file is hidden or not in java

import java.io.*;

public class IsHidden 
  public static void main(String[] args) 
  {  // enter the file name here.
	 // create file object.
     File file = new File("E:/includehelp.txt");
     // this will check is the file hidden or not.
     boolean blnHidden = file.isHidden();
     // return result in true or false condition.
     System.out.println("Is the file " + file.getPath() + " hidden ?: " + blnHidden);


Is the file E:\includehelp.txt hidden ?: false

Here, we are using an another method file.getPath() which returns the file name with path of that file, which is used while creating an object of “File” class.

Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.

Comments and Discussions

We are using Google to publish ads on our website; Google has its own privacy policies. They may save log, cookies on your system. Google may also collect information of your system like IP address, region, city, country. For more details please go through the Google’s privacy policy.