Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

file names  RSS feed

 
chris x barrett
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to check and see if there is a file with a certian name and i don't know how ...i don't want to read from the file just want to know the name of the file.
 
Stephen Foy
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could try

 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could do that, although since throwing an exception is expensive, this is very inefficient (and as written, it leaves the FileReader open... not good!) But it would be much better to use the java.io.File.exists() method:

 
chris barr
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks that helped alot.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!