• Post Reply Bookmark Topic Watch Topic
  • New Topic

How Do I Load A File From Current Diretory?

 
ernest fakudze
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all!
I need to load a file from the current directory (relative) without using the full path name (hardcoding). Currently it won't work unless I specify the full pathname e.g. E:\\Tomcat33\\webapps\\ROOT\\mysite\\myProperties.txt.
As you can see by the escape characters, I'm on a Windows System.
Please help me.
 
Shane Roylance
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be able to just do this:
fin = new FileInputStream("myfile.txt");
But if that doesn't work, you might try getting the directory from
System.getProperty("user.dir");
That should give you the current working directory.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!