Check if a file is hidden in Javan



The java.io.File class provides useful methods on file. This example shows how to check a file hidden or not by using the file.isHidden() method of File class.

Example

import java.io.File;

public class Main {
   public static void main(String[] args) {
      File file = new File("C:/java.txt");
      System.out.println(file.isHidden());
   }
}

Result

The above code sample will produce the following result (if the file "java.txt" exists and is hidden in 'C' drive).

true
Samual Sam
Samual Sam

Learning faster. Every day.


Advertisements