| Author |
Get a files in the classpath that match a given pattern
|
Marcio F. Lima
Greenhorn
Joined: Feb 11, 2010
Posts: 1
|
|
Hello guys!
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 ]
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
Hello Marcio, welcome to JavaRanch.
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.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
pawan chopra
Ranch Hand
Joined: Jan 23, 2008
Posts: 362
|
|
Hi Marcio,
I am not sure if I have understood your requirement correctly. See if the below code helps you:
I hope it helps otherwise let us know what exactly you are looking for?>
|
Pawan Chopra
SCJP - DuMmIeS mInD
|
 |
Srikanth Nalam
Greenhorn
Joined: Feb 23, 2010
Posts: 20
|
|
Hi Marcio,
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.
|
Thanks & Regards,
Srikanth Nalam.
|
 |
 |
|
|
subject: Get a files in the classpath that match a given pattern
|
|
|