• Post Reply Bookmark Topic Watch Topic
  • New Topic

Relative path of file in FileInputStream

 
nishant vats
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to open a file using realtive path...code goes here

new FileInputStream("..\\Nishant.properties")

but i am getting error
java.io.FileNotFoundException: ..\Nishant.properties (The system cannot find the file specified)


i have to acess the file using relative path ...Can I do that.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recommend creating a File object and printing out file.getCanonicalPath() so you see the absolute path you're trying to access. It's possible you just have the relative path or current working directory incorrect.
 
nishant vats
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have tried this also

File _file = new File(""..\\Nishant.properties");
System.out.println("*******Canonical path******"+ _file.getCanonicalPath());

but before exception is thrown while getting the handle of file so unable to see the SOP Message...

Nw Can you Clarify that.. :roll:
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I can't understand why I am getting an error, I simplify it to make sure I'm not missing something obvious. Try
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!