• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

ClassLoaders and directories

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know how to load all of the files inside a directory that is inside a war or jar? I have been using the ClassLoader to load config files which works great if you know the name of the file.
URL url = this.getClass().getClassLoader().getResource("config/manufacturerDataImport/import1.xml");
However I would like to be able to load all of the files inside the directory, and have the names be able to change. So If I had a URL that is
URL url = this.getClass().getClassLoader().getResource("config/manufacturerDataImport/");
I want to get a Collection of all of the xml files inside that URL directory.
Thanks,
-John
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't tried it and don't know how well it would work, but it might work to get the path of the URL (getPath()) and use that String to create a File object with which you might be able to use list() or listFiles() to get all the files.
[ March 21, 2003: Message edited by: Dirk Schreckmann ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nevermind any stumbling around I might recommend, it looks like Simon Brown has this one figured out over in The EJB and Other J2EE Technologies Forum.
Please don't post the same question in multiple forums, it can make it hard to follow a conversation.
Thanks
 
An elephant? An actual elephant. Into the apartment. How is the floor still here. Hold this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic