List of usage examples for org.apache.commons.compress.archivers.zip ZipArchiveEntry getExtraField
public ZipExtraField getExtraField(ZipShort type)
From source file:com.zimbra.cs.util.ZipUtil.java
/** * Use InfoZIP Unicode Extra Fields (if present) to set the filename *///from w w w . j a va 2s . c om private static String getNameFromUnicodeExtraPathIfPresent(ZipArchiveEntry zae) { UnicodePathExtraField unicodePathExtraField = (UnicodePathExtraField) zae .getExtraField(UnicodePathExtraField.UPATH_ID); if (null == unicodePathExtraField) { return null; } CRC32 crc32 = new CRC32(); crc32.update(zae.getRawName()); long origCRC32 = crc32.getValue(); if (origCRC32 == unicodePathExtraField.getNameCRC32()) { String val = convertBytesIfPossible(unicodePathExtraField.getUnicodeName(), StandardCharsets.UTF_8); if (null != val) { ZimbraLog.misc.debug("ZipUtil name '%s' from unicodeExtraPath", val); } return val; } return null; }
From source file:org.callimachusproject.io.ContentTypeExtraField.java
static String parseExtraField(ZipArchiveEntry entry) { try {//from w w w . j av a2 s .c o m ZipExtraField field = entry.getExtraField(ID); if (field == null) return null; byte[] data = field.getLocalFileDataData(); String str = new String(data, "UTF-8"); if (isContentType(str)) return str; } catch (UnsupportedEncodingException e) { throw new AssertionError(e); } return null; }
From source file:org.callimachusproject.io.MetaTypeExtraField.java
static MetaTypeExtraField parseExtraField(ZipArchiveEntry entry) { try {//from ww w .ja v a 2 s . c om ZipExtraField field = entry.getExtraField(ID); if (field == null) return null; byte[] data = field.getLocalFileDataData(); String str = new String(data, "UTF-8"); if ("FILE".equals(str)) return FILE; if ("FOLDER".equals(str)) return FOLDER; if ("RDF".equals(str)) return RDF; if ("RDFS".equals(str)) return RDFS; } catch (UnsupportedEncodingException e) { throw new AssertionError(e); } return null; }