Example usage for java.util.jar JarEntry getAttributes

List of usage examples for java.util.jar JarEntry getAttributes

Introduction

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

Prototype

public Attributes getAttributes() throws IOException 

Source Link

Document

Returns the Manifest Attributes for this entry, or null if none.

Usage

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();

        Attributes a = je.getAttributes();
        if (a != null) {
            Object[] nameValuePairs = a.entrySet().toArray();
            for (int j = 0; j < nameValuePairs.length; j++) {
                System.out.println(nameValuePairs[j]);
            }/*w w w .j a v a  2  s .c o m*/
        }
    }
}

From source file:Main.java

public static void main(String[] args) throws IOException {
    JarFile jf = new JarFile("a.jar");
    Enumeration e = jf.entries();
    while (e.hasMoreElements()) {
        JarEntry je = (JarEntry) e.nextElement();
        System.out.println(je.getName());
        long uncompressedSize = je.getSize();
        long compressedSize = je.getCompressedSize();
        long crc = je.getCrc();
        int method = je.getMethod();
        String comment = je.getComment();
        System.out.println(new Date(je.getTime()));
        System.out.println("from  " + uncompressedSize + " bytes to " + compressedSize);
        if (method == ZipEntry.STORED) {
            System.out.println("ZipEntry.STORED");
        } else if (method == ZipEntry.DEFLATED) {
            System.out.println(ZipEntry.DEFLATED);
        }/*from w ww  .j a v a  2s  .  c om*/
        System.out.println("Its CRC is " + crc);
        System.out.println(comment);
        System.out.println(je.isDirectory());

        Attributes a = je.getAttributes();
        if (a != null) {
            Object[] nameValuePairs = a.entrySet().toArray();
            for (int j = 0; j < nameValuePairs.length; j++) {
                System.out.println(nameValuePairs[j]);
            }
        }
        System.out.println();
    }
}

From source file:org.kepler.kar.KAREntry.java

/**
 * create a karentry from a jarentry//from w  ww . ja v a 2  s.  c o  m
 */
public KAREntry(JarEntry je) {
    super(je);
    try {
        Attributes atts = je.getAttributes();
        if (atts == null) {
            _attributes = new Attributes();
        } else {
            _attributes = atts;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    if (isDebugging)
        log.debug(this.debugString());
}

From source file:org.kepler.kar.KARFile.java

/**
 * Read the LSID from the attributes of the given entry and return it as a
 * KeplerLSID.//from ww  w.j a  va 2  s  .  com
 * 
 * @param entry
 * @return
 * @throws IOException
 */
private KeplerLSID getEntryLSID(JarEntry entry) throws IOException {
    Attributes atts = entry.getAttributes();
    if (atts == null) {
        return null;
    }

    String lsidStr = atts.getValue(KAREntry.LSID);
    if (lsidStr == null) {
        log.error("KAREntries must have an LSID and a type.");
        return null;
    }

    KeplerLSID lsid = null;
    try {
        lsid = new KeplerLSID(lsidStr);
    } catch (Exception e) {
        log.warn(lsidStr + " is not a properly formatted KeplerLSID");
        return null;
    }
    return lsid;
}

From source file:org.kepler.kar.KARFile.java

/**
 * Read the type attribute from the given entry and return it as a string.
 * /*from w  w w .j  a v  a 2s .c om*/
 * @param entry
 * @return
 * @throws IOException
 */
private String getEntryType(JarEntry entry) throws IOException {
    Attributes atts = entry.getAttributes();
    if (atts == null) {
        return null;
    }
    String type = atts.getValue(KAREntry.TYPE);
    return type;
}