Search in sources :

Example 1 with ZipInputStream

use of net.lingala.zip4j.io.inputstream.ZipInputStream in project J2ME-Loader by nikita36078.

the class AppInstaller method loadManifest.

private Descriptor loadManifest(File jar) throws IOException {
    ZipFile zip = new ZipFile(jar);
    FileHeader manifest = zip.getFileHeader(JarFile.MANIFEST_NAME);
    if (manifest == null)
        throw new IOException("JAR not have " + JarFile.MANIFEST_NAME);
    try (ZipInputStream is = zip.getInputStream(manifest)) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream(20480);
        byte[] buf = new byte[4096];
        int read;
        while ((read = is.read(buf)) != -1) {
            baos.write(buf, 0, read);
        }
        return new Descriptor(baos.toString(), false);
    }
}
Also used : ZipInputStream(net.lingala.zip4j.io.inputstream.ZipInputStream) ZipFile(net.lingala.zip4j.ZipFile) Descriptor(ru.woesss.j2me.jar.Descriptor) IOException(java.io.IOException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FileHeader(net.lingala.zip4j.model.FileHeader)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ZipFile (net.lingala.zip4j.ZipFile)1 ZipInputStream (net.lingala.zip4j.io.inputstream.ZipInputStream)1 FileHeader (net.lingala.zip4j.model.FileHeader)1 Descriptor (ru.woesss.j2me.jar.Descriptor)1