C# Corner
Tech
News
Videos
Forums
Trainings
Books
Live
More
Interviews
Events
Jobs
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Checking File Or Directory in the System in Java Program
WhatsApp
Alagunila Meganathan
Aug 03
2016
552
0
0
FileOrDirectory.rar
import
java.io.*;
public
class
FileOrDirectoryExists{
public
static
void
main(String args[]){
File file=
new
File(
"Any file name or directory whether exists or not"
);
boolean
exists = file.exists();
if
(!exists) {
// It returns false if File or directory does not exist
System.out.println(
"the file or directory you are searching does not exist : "
+ exists);
}
else
{
// It returns true if File or directory exists
System.out.println(
"the file or directory you are searching does exist : "
+ exists);
}
}
}
Directory
File
JAva
Up Next
Checking File Or Directory in the System in Java Program