Valhalla Legends Forums Archive | Java Programming | Existance of files...

AuthorMessageTime
iago
Is there some easy way to check whether or not a file exists? As far as I can tell, the best way to do it (without using an exec()) is to try to open it to read from it and let it throw an exception.

What I want to be able to do is, if a user tries to create a file names MrFile.txt, and it already exists, to make it MrFile_1.txt, if that exists, make it MrFile_2.txt, etc. until it finds one. Is there some easy way to do that?

Thanks!
-iago
January 27, 2004, 2:19 PM
Tuberload
I believe File.exists()...
January 27, 2004, 4:40 PM

Search