Check if a file is hidden in Java

Object Oriented ProgrammingJava Programming Java8

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
raja
Published on 20-Jul-2018 13:53:11
Advertisements