Sunday, 21 August 2016

HOW TO CHECK IF FILE IS HIDDEN IN JAVA


public class HiddenFile {

    
// In Unix hidden file is begins with “.” And in Window is it “,”
   And it should not be directory,
   There is a method for cheking hidden file
                  Syntax of the method:

  public static boolean isHidden(Path path) throws IOException

     public static void main(String[] args) {
           String path = "D:/neeraj.txt";

           File file = new File(path);

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

     }

}


No comments:

Post a Comment