From: Christian M. <vc...@cl...> - 2002-08-05 15:17:06
|
Hi all, I was thinking about a new method to load xml files in the datastore. I do not like the hardcoded filename approach nor the class one( it will = end with xml files all around java classes) My idea is to be able to load a .jar containing all the xml files ( = created wih ant for example at deployment time) public void StoreJarFile(string fileName) { JarFile jarFile =3D new = JarFile((Thread.currentThread().getContextClassLoader().getResource("file= Name")).getFile()); if(jarFile!=3Dnull) { Enumeration enum =3D jarFile.entries(); while(enum.hasMoreElements()) { ZipEntry z =3D (ZipEntry)enum.nextElement(); if(z.getName().endsWith(".xml")) this.storeInputStream(jarFile.getInputStream(z)); = =20 } } else log.error("Could not find "+fileName+"in the classpath"); } Such jar file could be in WEB-INF/classes in a web app. Let me know what do you think about it. Chris |