Java Programs

Java Practice

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?


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) { 
    // 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.

Java File Handling Programs »

Comments and Discussions!

Load comments ↻

Copyright © 2024 www.includehelp.com. All rights reserved.