A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Java program to check whether a file is hidden or not
Q:

Java program to check whether a file is hidden or not

0

Given a file, and we have to check whether it is hidden or not using Java program?

File.isHidden()

This is a method of "File" class, which returns true if a file has hidden property and return false if it is not.

In this program, we are using a file named "includehelp.txt" which is stored in "E:\" in my system, program will check its hidden property and returns the result.

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program to check file is hidden or not in java

import java.io.*;

public class IsHidden {
  public static void main(String[] args) { 
    // create file object.
    File file = new File("E:/includehelp.txt");

    // this will check is the file hidden or not.
    boolean blnHidden = file.isHidden();

    // return result in true or false condition.
    System.out.println("Is the file " + file.getPath() + " hidden ?: " + blnHidden);
  }
}

Output

Is the file E:\includehelp.txt hidden ?: false

Here, we are using an another method file.getPath() which returns the file name with path of that file, which is used while creating an object of “File” class.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now