
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Determine if File or Directory is hidden in Java
The method java.io.File.isHidden() is used to check whether the file or directory specified by the abstract path name is hidden in Java. This method returns true if the file or directory specified by the abstract path name is hidden and false otherwise.
A program that demonstrates this is given as follows −
Example
import java.io.File; public class Demo { public static void main(String[] args) { try { File file = new File("c:/JavaProgram/demo1.txt"); file.createNewFile(); System.out.println(file.isHidden()); } catch(Exception e) { e.printStackTrace(); } } }
The output of the above program is as follows −
Output
false
Now let us understand the above program.
The method java.io.File.isHidden() is used to check whether the file or directory specified by the abstract path name is hidden and the boolean value that is returned by the method is printed. A code snippet that demonstrates this is given as follows −
try { File file = new File("c:/JavaProgram/demo1.txt"); file.createNewFile(); System.out.println(file.isHidden()); } catch(Exception e) { e.printStackTrace(); }
- Related Questions & Answers
- Determine if file or directory exists in Java
- Check if a file is hidden in Java
- Java Program to check if a file or directory is readable
- Rename file or directory in Java
- Check whether the file is hidden or not in Java
- Check if a File is hidden in C#
- Check for file or directory in Java
- Delete the file or directory in Java
- Java Program to delete file or directory
- How to check if a file is a directory or a regular file in Python?
- Delete file or directory on termination in Java
- Mark file or directory Read Only in Java
- Java Program to rename a file or directory
- Java Program to get name of specified file or directory
- Specify a path for a file or a directory in Java
Advertisements