• Post Reply Bookmark Topic Watch Topic
  • New Topic

FileNotFoundException  RSS feed

 
Andy Smith
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI
I am using FileInputStream and passing the name of the file "info.properties".

The file is in classpath but still it is not able to load the file it says

java.io.FileNotFoundException "The system cannot find the file specified"

i dont want to give the absolute path,

can any one help me plz?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming you're usimg new File("info.properties") or similar?
This looks for the file in the 'current directory', but it isn't always clear what this is. It's a long story. Assumming you know what the current directory is you can put the info file there, but the other way is to put the file on the classpath and use the ClasslOader to find the file.

Again without seeing any code I'm assuming this is what you should be doing. You can always use getClassLoader().getResource(...), but since (I assume) you're going to load this into a java.util.Properties instance, it's easier to access it directly as a Stream then pass this to the Properties



I haven't actually tested the above, it may need some fixing. If you felt like posting some sample code we may have a better idea what you were trying to do...

Dave
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!