Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems with file

 
Anand Loni
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have one java file in a package which has one properties file. Now I want to access this properties file through java file. I dont want to specify location of the properties file.
When I just pass name of properties file to File then its unable to find file.
Please help me in this problem.

Regards,
Anand
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want to use one of the getResource() methods in Class or ClassLoader. From an instance method of a class, you can just say something like

 
Anand Loni
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic