1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
private String readJarFile(String JarFile, String name) {
try {
//Je recherche ma classe dans le fichier JAR
JarFile jf = new JarFile(jarFile);
Enumeration e = jf.entries();
int i = 0;
JarEntry je = null;
for(i=0;e.hasMoreElements() && i<1000;i++) {
je = (JarEntry)e.nextElement();
if(je.toString().replaceAll("/",".").replace(".class","").equals(name)) {
i = 1001;
}
}
// Je commence à lire le contenu, c'est là où j'ai un problème...
InputStream is = jf.getInputStream(je);
JarInputStream jis = new JarInputStream(is);
Byte lu = 0;
String contenu = "";
char c = ' ';
i = 0;
while((lu=(byte)jis.read()) != -1) {
c = (char)(int)lu;
System.out.println(lu);
contenu += c;
i++;
}
System.out.println("JE-FILE : "+je.getCompressedSize() );
System.out.println("CONTENU : "+i);
return contenu;
}
catch(Exception e) {
log.fatal(e);
}
return null;
} |
Partager