Share on Google+Share on Google+

Java file isHidden

This section demonstrates you the use of method isHidden().

Java file isHidden

This section demonstrates you the use of method isHidden().

Description of code:

This method determines whether the file or directory is hidden or not. It returns boolean value, if the file is hidden, it returns true otherwise false. It is system dependent. If you are working on UNIX platform, the file is considered hidden, if its name began with a dot(.) and if you are working on Windows platform a file is considered to be hidden, if the file is marked as hidden in the file properties.

Now to check this method, we have marked the file 'hidden' through its file properties. Then in the example, we have created an object of File class and parse the file. Through its object, we have called the method isHidden(). On executing the code, the method return true which means the file is hidden.

Here is the code:


public class FileHidden {
	public static void main(String[] args) {
		File myFile = new File("C:/examples.txt");
		System.out.println("Is " + myFile.getName() + " hidden?: "
				+ (myFile.isHidden()));

We have used isHidden() method to check whether the file is hidden or not. You can use this method to check any file or directory from the system.


Is examples.txt hidden?: true


Posted on: April 25, 2006 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.