We are moved to new domain
Click -> www.ehowtonow.com
Wednesday, 24 May 2017

How to check directory or file is hidden using Java

boolean java.io.File.isHidden()

Tests whether the file named by this abstract pathname is a hidden file. The exact definition of hidden is system-dependent. On UNIX systems, a file is considered to be hidden if its name begins with a period character ('.'). On Microsoft Windows systems, a file is considered to be hidden if it has been marked as such in the filesystem.

Returns:
true if and only if the file denoted by this abstract pathname is hidden according to the conventions of the underlying platform

Throws:
SecurityException - If a security manager exists and its java.lang.SecurityManager.checkRead(java.lang.String) method denies read access to the file

Since:
1.2
HiddenFile.java
package com.javatutorialcorner.directory;

import java.io.File;

public class HiddenFile {

public static void main(String[] args) {

File file = new File("C:/JTC/Java/Examples/Directory/File/java.txt");

System.out.println("Is Hidden : "+file.isHidden());

}

}
Output
Is Hidden : false

Shop and help us

Flipkart Offer Snapdeal offer Amazon.in offer Amazon.com offer
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments

0 comments:

Post a Comment

Item Reviewed: How to check directory or file is hidden using Java Rating: 5 Reviewed By: eHowToNow