How to Check Hidden File in Java?

If you want to check if a file is hidden or not. Then use the below code snippet. The method isHidden() in the File class is used for checking if the file is hidden or not. This is simple utility which is useful when you are working with the File operations.

package javabeat.net.io;

import java.io.File;
import java.io.IOException;

public class HiddenCheck {
	public static void main(String[] args) throws IOException
    {
    	File file = new File("d:\\CreateFile.txt");

    	if(file.isHidden()){
    		System.out.println("This is a hidden file");
    	}else{
    		System.out.println("This file is not hidden");
    	}
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Pin It on Pinterest

Share This

Share this post with your friends!

Share This

Share this post with your friends!