Get a files in the classpath that match a given pattern
Marcio F. Lima
Joined: Feb 11, 2010
Let me try to explain what I need.
I have some config files in my classpath in both the classes directory and inside some jars also.
They follow a predefined naming convention. I'd like to get their contents. The problem is that they are in different subdirectories. Here's the example:
I'd like to have the reference to each of these files so that I can load them using ResourceBundle.getBundle(configFileFQN).
I don't think there's a method I can use to retrieve these files, I guess I'll need to look for them in each package or something. I don't know.
Does anyone have a clue?
Thanks in advance!
Marcio Fernandes de Lima
[ e-mail address and phone number deleted ]
I deleted your e-mail address and phone number from your post. It's better not to post personal contact details on Internet forums like that. Did you know that there are hackers who search the Internet with automated tools to harvest things like e-mail addresses? They'll put you on spam lists and your inbox will be filled with spam e-mail. Likewise, I don't think it's a good idea to shout your personal phone number to the whole world.
I think you don't have to worry about in which jar or directory the files are.
To load the content from the properties file
1.Ensure that it is in classpath
2.Note down the the full qualified name of that file (ex: com.company.module5.config.properties)
3.Pass that full qualified name to the getBundle method of ResourBudle to get the reference and load data.