How can I read an entry from a jar file?

John Zukowski

Basically, open the .jar file, find the entry you want, then read it:

JarFile jar = new JarFile(jarfile);
ZipEntry entry = jar.getEntry(entryname);
InputStream is = jar.getInputStream(entry);
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
  System.out.println(line);
}
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact