How To find hidden Files in Java
Here in this blog we will explain how to find hidden file in system can be linux or windows using File operation in java
As per Java Document method details are below
As per Java Document method details are below
isHidden
public boolean 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
method denies read access to the fileSecurityManager.checkRead(java.lang.String)
- Sample Code :
package com.learnjavabyanand; import java.io.*; /** * @author Anand * */ public class CheckHideenFiles { public static void main(String[] args) { try { File file = new File("C:/users/ananddw/codeDetails.txt"); if (file.isHidden()) { System.out.println(file.getName() + " is Hidden File"); } else { System.out.println(file.getName() + " File is not Hidden "); } } catch (Exception e) { e.getMessage(); } } }
Comments
Post a Comment