Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
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
505
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);
}
}
}
JAva
File
Directory
Up Next
Checking File Or Directory in the System in Java Program