use of net.lingala.zip4j.exception.ZipException in project Auto.js by hyb1996.
the class AndroidClassLoader method defineClass.
/**
* {@inheritDoc}
*/
@Override
public Class<?> defineClass(String name, byte[] data) {
try {
final ZipFile zipFile = new ZipFile(classFile);
final ZipParameters parameters = new ZipParameters();
parameters.setFileNameInZip(name.replace('.', '/') + ".class");
parameters.setSourceExternalStream(true);
zipFile.addStream(new ByteArrayInputStream(data), parameters);
return dexJar().loadClass(name, parent);
} catch (IOException | ZipException e) {
throw new FatalLoadingException(e);
} finally {
dexFile.delete();
odexOatFile.delete();
}
}
use of net.lingala.zip4j.exception.ZipException in project codeforces-commons by Codeforces.
the class ZipUtil method getZipArchiveInfo.
public static ZipArchiveInfo getZipArchiveInfo(File zipFile) throws IOException {
try {
ZipFile internalZipFile = new ZipFile(zipFile);
long totalSize = 0;
long entryCount = 0;
for (Object fileHeader : internalZipFile.getFileHeaders()) {
FileHeader entry = (FileHeader) fileHeader;
long size = entry.getUncompressedSize();
if (size > 0L) {
totalSize += size;
}
++entryCount;
}
return new ZipArchiveInfo(totalSize, entryCount);
} catch (ZipException e) {
throw new IOException("Can't get ZIP-archive info.", e);
}
}
use of net.lingala.zip4j.exception.ZipException in project codeforces-commons by Codeforces.
the class ZipUtil method writeZipEntryBytes.
public static void writeZipEntryBytes(File zipFile, String zipEntryPath, OutputStream outputStream) throws IOException {
TFile trueZipFile = new TFile(new File(zipFile, zipEntryPath));
try {
try {
InputStream inputStream;
if (trueZipFile.isArchive()) {
synchronizeQuietly(trueZipFile);
ZipFile internalZipFile = new ZipFile(zipFile);
inputStream = internalZipFile.getInputStream(internalZipFile.getFileHeader(zipEntryPath));
} else {
inputStream = new TFileInputStream(trueZipFile);
}
IoUtil.copy(inputStream, outputStream);
} catch (ZipException e) {
throw new IOException("Can't write ZIP-entry bytes.", e);
}
} finally {
IoUtil.closeQuietly(outputStream);
synchronizeQuietly(trueZipFile);
}
}
Aggregations