• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading a file only if it exists  RSS feed

 
Jim Michaelson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to read a file only if it exists, and skip that step if it doesn't (so that no exceptions are thrown).

How do I check to see if a file exists?

Thanks!
 
Steve McCann
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the exists() method in the java.io.File class.
Have a look at the Java API documentation here

Cheers
Steve
[ June 10, 2005: Message edited by: Steve McCann ]
 
Jim Michaelson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!