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;

">


















Check if a file is hidden in Java\\n



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
Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements