This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Problems with file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problems with file " Watch "Problems with file " New topic

Problems with file

Anand Loni
Ranch Hand

Joined: Jan 20, 2006
Posts: 150

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.


~ Anand,
SCJP 1.5, SCWCD 1.5
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24183

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

[Jess in Action][AskingGoodQuestions]
Anand Loni
Ranch Hand

Joined: Jan 20, 2006
Posts: 150
thanks a lot
I agree. Here's the link:
subject: Problems with file
Similar Threads
read properties in my java application defined in spring bean "PropertyPlaceholderConfigurer"
how to run java -jar with args?
where to place .properties file
configure properties file
JLIST Store and retreive data to Properties