本文整理匯總了Java中org.zeroturnaround.zip.ZipUtil.unpackEntry方法的典型用法代碼示例。如果您正苦於以下問題:Java ZipUtil.unpackEntry方法的具體用法?Java ZipUtil.unpackEntry怎麽用?Java ZipUtil.unpackEntry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.zeroturnaround.zip.ZipUtil
的用法示例。
在下文中一共展示了ZipUtil.unpackEntry方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: readPackage
import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
public P3Package readPackage(File file) throws PackageException {
try {
if (!ZipUtil.containsEntry(file, "package.json")) {
throw new PackageException("No package schema found");
}
byte[] schemaBytes = ZipUtil.unpackEntry(file, "package.json");
String schemaString = new String(schemaBytes);
JSONObject schema = new JSONObject(schemaString);
P3Package p3 = readSchema(schema);
p3.setLocalPath(file.getPath());
return p3;
}
catch(JSONException e) {
throw new PackageException("Invalid package schema", e);
}
}
示例2: updateManifest
import org.zeroturnaround.zip.ZipUtil; //導入方法依賴的package包/類
static void updateManifest(Log pLogger, Map<String, String> pAdditionalManifestEntries, Path pPath) throws IOException
{
String manifestPath = "META-INF/MANIFEST.MF";
Manifest manifest;
byte[] zipContent = ZipUtil.unpackEntry(pPath.toFile(), manifestPath);
if (zipContent == null)
manifest = new Manifest();
else
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(zipContent))
{
manifest = new Manifest(inputStream);
}
Attributes mainAttributes = manifest.getMainAttributes();
if (pAdditionalManifestEntries != null)
for (Map.Entry<String, String> entry : pAdditionalManifestEntries.entrySet())
mainAttributes.putValue(entry.getKey(), entry.getValue());
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream())
{
manifest.write(outputStream);
ZipUtil.replaceEntry(pPath.toFile(), manifestPath, outputStream.toByteArray());
pLogger.info("Updated manifest for " + pPath + ".");
}
}