Java Example – Checking Whether a File Is Hidden
The following example demonstrates using the file.isHidden() method of the File class to check whether a file is hidden:
Main.java File
import
java
.
io
.
File
;
public
class
Main
{
public
static
void
main
(
String
[
]
args
)
{
File
file
=
new
File
(
"
C:/Demo.txt
"
)
;
System
.
out
.
println
(
file
.
isHidden
(
)
)
;
}
}
The output of the above code is (Demo.txt is a hidden file):
True
Java Examples