use of the.bytecode.club.bytecodeviewer.bootloader.resource.jar.JarResource in project bytecode-viewer by Konloch.
the class ExternalLibrary method load.
/* (non-Javadoc)
* @see the.bytecode.club.bytecodeviewer.loadermodel.ExternalResource#load()
*/
@Override
public JarContents<ClassNode> load() throws IOException {
JarContents<ClassNode> contents = new JarContents<>();
JarURLConnection con = (JarURLConnection) getLocation().openConnection();
JarFile jar = con.getJarFile();
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
try (InputStream is = jar.getInputStream(entry)) {
byte[] bytes = read(is);
if (entry.getName().endsWith(".class")) {
ClassNode cn = create(bytes);
contents.getClassContents().add(cn);
} else {
JarResource resource = new JarResource(entry.getName(), bytes);
contents.getResourceContents().add(resource);
}
}
}
return contents;
}
Aggregations