下面列出了java.util.zip.ZipException#getMessage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void addZipEntryAndWrite(ZipOutputStream zipStream,
String onePinFileName, byte[] onePinDataCsv) throws IOException {
ZipEntry zipEntry = new ZipEntry(onePinFileName);
try {
zipStream.putNextEntry(zipEntry);
zipStream.write(onePinDataCsv);
zipStream.closeEntry();
} catch (ZipException zipException) {
String message = zipException.getMessage();
if (message != null && message.contains("duplicate")) {
log.warn("Duplicate zip entry {}. Wrong report configuration.", onePinFileName);
} else {
log.error("Error compressing report file.", message);
throw zipException;
}
} catch (IOException e) {
log.error("Error compressing report file.", e.getMessage());
throw e;
}
}
/**
* Content accessor.
*
* @return InputStream
*/
@Override
public InputStream streamContent()
throws IOException {
try {
if (binaryContent == null) {
InputStream is = base.getInputStream(entry);
inputStream = is;
return is;
}
} catch (ZipException e) {
throw new IOException(e.getMessage(), e);
}
return super.streamContent();
}
/**
* Content accessor.
*
* @return InputStream
*/
@Override
public InputStream streamContent()
throws IOException {
try {
if (binaryContent == null) {
InputStream is = base.getInputStream(entry);
inputStream = is;
return is;
}
} catch (ZipException e) {
throw new IOException(e.getMessage(), e);
}
return super.streamContent();
}
public ZipArchive(final File zipfile) throws IOException {
try {
this.zipfile = new ZipFile(zipfile);
} catch (final ZipException ex) {
final IOException exx = new IOException(ex.getMessage());
exx.initCause(ex);
throw exx;
}
}