Check if a File is Hidden in Java

      No Comments on Check if a File is Hidden in Java

In Java, whether a file is hidden or not , it can be checked using isHidden() method of

Syntax of File isHidden() Method:

public boolean isHidden()

If a file is hidden then File isHidden() method returns true otherwise it returns false.

File object can refer to a directory or any other file.

Demo Program : File isHidden() Method

The below Program demonstrates how to check whether a file is hidden or not.

package com.masterjavatutorial;
public class Example {

	public static void main(String[] args) {

		 File file = new File("/srv/KT/Grunt.txt");
		     System.out.println("File is Hidden");
		     System.out.println("File is not Hidden");
		 File file1 = new File("/srv/softwares");
		     System.out.println("Directory is Hidden");
		     System.out.println("Directory is not Hidden");