How to check if a file is hidden in Java
Published: August 23, 2010 , Updated: August 23, 2010 , Author: mkyong
A Java program to demonstrate the use of java.io.File isHidden() to check if a file is hidden.
package com.mkyong; import java.io.File; import java.io.IOException; public class FileHidden { public static void main(String[] args) throws IOException { File file = new File("c:/hidden-file.txt"); if(file.isHidden()){ System.out.println("This file is hidden"); }else{ System.out.println("This file is not hidden"); } } }
Note
The isHidden() method is system dependent, on UNIX platform, a file is considered hidden if it’s name is begins with a “dot” symbol (‘.’); On Microsoft Windows platform, a file is considered to be hidden, if it’s marked as hidden in the file properties.
The isHidden() method is system dependent, on UNIX platform, a file is considered hidden if it’s name is begins with a “dot” symbol (‘.’); On Microsoft Windows platform, a file is considered to be hidden, if it’s marked as hidden in the file properties.
Any Java questions or problems? please post at this JavaNullPointer.com forum, see you there ~