How to determine if a directory is hidden in Java

1 Answer

0 votes
import java.io.File;
import java.io.IOException;
 
public class MyClass {
 
    public static void main(String[] args) throws IOException {
 
        try {
 
            File file = new File("d://tmp");
    
            boolean b = file.isHidden();
 
            if (b)
                System.out.println("The directory is hidden");
            else
                System.out.println("The directory is not hidden");
 
        } catch (Exception e) {
            System.out.print(e);
        }
    }
}
 
 
 
 
/*
         
run:
   
The directory is not hidden
     
*/

 



answered Nov 16, 2016 by avibootz
edited Nov 15, 2023 by avibootz

Related questions

1 answer 177 views
2 answers 208 views
3 answers 151 views
2 answers 207 views
1 answer 187 views
...