Checking the existence of a file is easy in Java and is a method behind. The file.exists() method in java.io.File does the thing. Here is a sample tutorial.
f.exists(): Check the existence of a file. If the file is present, it returns true else it returns false.
-----------------------------------
Output
-----------------------------------
The name of the file is myfile.txt
Does the file exist? false
MPVWCWTNM4YU
f.exists(): Check the existence of a file. If the file is present, it returns true else it returns false.
-----------------------------------
Output
-----------------------------------
The name of the file is myfile.txt
Does the file exist? false
MPVWCWTNM4YU
No comments:
Post a Comment