Example usage for java.util.jar JarFile JarFile

List of usage examples for java.util.jar JarFile JarFile

Introduction

In this page you can find the example usage for java.util.jar JarFile JarFile.

Prototype

public JarFile(File file) throws IOException 

Source Link

Document

Creates a new JarFile to read from the specified File object.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    JarFile f = new JarFile("a.jar");
    Pack200.Packer packer = Pack200.newPacker();
    OutputStream out = new FileOutputStream("a.pack");
    packer.pack(f, out);//  w w  w  .  j a v  a  2s . c o m
    out.close();
}

From source file:Main.java

public static void main(String[] args) throws IOException {
    JarFile jf = new JarFile(args[0]);
    Enumeration e = jf.entries();
    while (e.hasMoreElements()) {
        JarEntry je = (JarEntry) e.nextElement();
        String name = je.getName();
        System.out.println(name);
    }/*from   w w w.ja  v  a 2 s . c om*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JarFile jarfile = new JarFile("filename.jar");

    Manifest manifest = jarfile.getManifest();

    OutputStream fos = new FileOutputStream("manifest");
    jarfile.getManifest().write(fos);//  w  w  w. ja v a2s.  c  o m
    fos.close();
}

From source file:MainClass.java

public static void main(String[] args) throws IOException {

    JarFile jf = new JarFile(args[0]);
    Enumeration e = jf.entries();
    while (e.hasMoreElements()) {
        JarEntry je = (JarEntry) e.nextElement();
        String name = je.getName();
        System.out.println(name);
    }//w  ww  .jav  a 2 s . c  om
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JarFile jarfile = new JarFile("filename.jar");

    Manifest manifest = jarfile.getManifest();

    Attributes attrs = (Attributes) manifest.getMainAttributes();

    for (Iterator it = attrs.keySet().iterator(); it.hasNext();) {
        Attributes.Name attrName = (Attributes.Name) it.next();

        String attrValue = attrs.getValue(attrName);
    }//from  ww w . j ava  2 s . c o  m
}

From source file:Main.java

public static void main(String args[]) throws IOException {

    JarFile jarFile = new JarFile("c:/abc/yourJarFileName.jar");
    Enumeration<JarEntry> e = jarFile.entries();
    while (e.hasMoreElements()) {
        process(e.nextElement());//from  w ww  .  j a  v  a2s.co m
    }
    jarFile.close();
}

From source file:MainClass.java

public static void main(String[] args) throws IOException {

    JarFile jf = new JarFile(args[0]);
    Enumeration e = jf.entries();
    while (e.hasMoreElements()) {
        JarEntry je = (JarEntry) e.nextElement();
        String name = je.getName();

        long crc = je.getCrc();
        System.out.println("Its CRC is " + crc);
        String comment = je.getComment();
        if (comment != null && !comment.equals("")) {
            System.out.println(comment);
        }/*from  w  w w. j  a v a  2s  .c  om*/
        if (je.isDirectory()) {
            System.out.println(name + " is a directory");
        }

    }
}

From source file:Main.java

public static void main(String args[]) throws IOException {

    JarFile jarFile = new JarFile(new File("c:/abc/yourJarFileName.jar"));
    Enumeration<JarEntry> e = jarFile.entries();
    while (e.hasMoreElements()) {
        process(e.nextElement());//from w  ww .  j  ava  2s.c o  m
    }
    jarFile.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {

    OutputStream out = null;//from www.j  a v a2s . co  m

    JarFile f = new JarFile(args[0]);
    Pack200.Packer packer = Pack200.newPacker();
    out = new FileOutputStream(args[0] + ".pack");
    packer.pack(f, out);
    out.close();
}

From source file:Main.java

public static void main(String[] args) throws IOException {

    JarFile jf = new JarFile(args[0]);
    Enumeration e = jf.entries();
    while (e.hasMoreElements()) {
        JarEntry je = (JarEntry) e.nextElement();
        String name = je.getName();
        Date lastModified = new Date(je.getTime());
        long uncompressedSize = je.getSize();
        long compressedSize = je.getCompressedSize();

        System.out.println(lastModified);
        System.out.println(uncompressedSize);
        System.out.println(compressedSize);
    }//from  w  ww .  j  ava2  s . c  o m
}