This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Listing files embedded in an EAR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Listing files embedded in an EAR" Watch "Listing files embedded in an EAR" New topic
Author

Listing files embedded in an EAR

vince walker
Greenhorn

Joined: Aug 30, 2013
Posts: 1
I have XML files which I want to store in an EAR. When the app starts, I want to read all the XML files and load them into memory. I found getClass().getResourceAsStream(...) to load a file if I know the name. But how can I list all the files and iterate through them if I don't know the names in advance?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Store a text file along with the XML files which contains a list of the names of the XML files.
Balaji Manoharan Bm
Greenhorn

Joined: Sep 22, 2013
Posts: 13
Give the directory name as input to getResourceAsStream() and the use File.listFiles() method to know all the files available in that directory.
 
Consider Paul's rocket mass heater.
 
subject: Listing files embedded in an EAR
 
Similar Threads
EAR Isolation in Jboss 4.0.2
Question of class loaders.
jxm stop ear application, including war
Loading multiple log4j.xml files
EAR Isolation in Jboss 4.0.2