File isHidden() in Java

isHidden(): This method is available in the java.io.File class of Java.

Syntax:

boolean java.io.File.isHidden()

This method tests whether the file named by this abstract pathname is a hidden file.

Note:

1. On UNIX systems, a file is considered to be hidden if its name begins with a period character ('.').

2. On Microsoft Windows systems, a file is considered to be hidden if it has been marked as such in the file system.

Parameters: NA

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.

Approach

Java

import java.io.File;

public class FileisHidden {
    public static void main(String[] args) {

        String pathname = "D:\\hello.txt";
        File file = new File(pathname);

        System.out.println(file.isHidden());
    }
}

Output:

false


No comments:

Post a Comment