Home Tutorial Java Corejava How to check a file is hidden or not in java

 
 

Share on Google+Share on Google+
How to check a file is hidden or not in java
Posted on: April 12, 2010 at 12:00 AM
Advertisement
This tutorial demonstrate how to check a file is hidden or not in java.

Description:

This example demonstrate how to check a file is hidden at a given path or not.  The method isHidden() of the File class check for its hidden property of a file. As in the file path we see '\' (backslash) that is used to denote file separation but here in this example File.separator is used.  

Code:

import java.io.File;

public class CheckForHidden {
  public static void main(String[] a) {
    File findFile = new File("C:" + File.separator + "java-tutorial"
        + File.separator + "Test" + File.separator +
        
"anyfile.java");
    System.out.println(findFile.isHidden());
  }
}

Output:

The output of this example is either true or false depends on the file have hidden property at the specified path that is set in the program above.

Advertisement

Related Tags for How to check a file is hidden or not in java:


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.

Posted on: April 12, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com