本文整理了Java中java.util.zip.ZipOutputStream.finish()
方法的一些代码示例,展示了ZipOutputStream.finish()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipOutputStream.finish()
方法的具体详情如下:
包路径:java.util.zip.ZipOutputStream
类名称:ZipOutputStream
方法名:finish
[英]Indicates that all entries have been written to the stream. Any terminal information is written to the underlying stream.
[中]指示所有条目都已写入流。任何终端信息都会写入底层流。
代码示例来源:origin: pentaho/pentaho-kettle
@Override
public void close() throws IOException {
ZipOutputStream zos = (ZipOutputStream) delegate;
zos.flush();
zos.closeEntry();
zos.finish();
zos.close();
}
代码示例来源:origin: Blankj/AndroidUtilCode
/**
* Zip the files.
*
* @param srcFiles The source of files.
* @param zipFile The ZIP file.
* @param comment The comment.
* @return {@code true}: success<br>{@code false}: fail
* @throws IOException if an I/O error has occurred
*/
public static boolean zipFiles(final Collection<File> srcFiles,
final File zipFile,
final String comment)
throws IOException {
if (srcFiles == null || zipFile == null) return false;
ZipOutputStream zos = null;
try {
zos = new ZipOutputStream(new FileOutputStream(zipFile));
for (File srcFile : srcFiles) {
if (!zipFile(srcFile, "", zos, comment)) return false;
}
return true;
} finally {
if (zos != null) {
zos.finish();
zos.close();
}
}
}
代码示例来源:origin: robovm/robovm
/**
* Closes the current {@code ZipEntry}, if any, and the underlying output
* stream. If the stream is already closed this method does nothing.
*
* @throws IOException
* If an error occurs closing the stream.
*/
@Override
public void close() throws IOException {
// don't call super.close() because that calls finish() conditionally
if (out != null) {
finish();
def.end();
out.close();
out = null;
}
}
代码示例来源:origin: Blankj/AndroidUtilCode
/**
* Zip the files.
*
* @param srcFilePaths The paths of source files.
* @param zipFilePath The path of ZIP file.
* @param comment The comment.
* @return {@code true}: success<br>{@code false}: fail
* @throws IOException if an I/O error has occurred
*/
public static boolean zipFiles(final Collection<String> srcFilePaths,
final String zipFilePath,
final String comment)
throws IOException {
if (srcFilePaths == null || zipFilePath == null) return false;
ZipOutputStream zos = null;
try {
zos = new ZipOutputStream(new FileOutputStream(zipFilePath));
for (String srcFile : srcFilePaths) {
if (!zipFile(getFileByPath(srcFile), "", zos, comment)) return false;
}
return true;
} finally {
if (zos != null) {
zos.finish();
zos.close();
}
}
}
代码示例来源:origin: apache/incubator-druid
log.info("Adding file[%s] with size[%,d]. Total size so far[%,d]", file, file.length(), totalSize);
if (file.length() > Integer.MAX_VALUE) {
zipOut.finish();
throw new IOE("file[%s] too large [%,d]", file, file.length());
zipOut.finish();
代码示例来源:origin: pentaho/pentaho-kettle
private boolean closeFile() {
boolean retval = false;
if ( data.OpenedNewFile ) {
try {
// Close the parent element
data.writer.writeEndElement();
data.writer.writeCharacters( EOL );
// System.out.println("Closed xml file...");
data.writer.writeEndDocument();
data.writer.close();
if ( meta.isZipped() ) {
// System.out.println("close zip entry ");
data.zip.closeEntry();
// System.out.println("finish file...");
data.zip.finish();
data.zip.close();
}
closeOutputStream( outputStream );
retval = true;
} catch ( Exception e ) {
// Ignore errors
}
}
return retval;
}
代码示例来源:origin: zeroturnaround/zt-zip
private static void pack(ZipEntrySource[] entries, OutputStream os, boolean closeStream) {
try {
ZipOutputStream out = new ZipOutputStream(os);
for (int i = 0; i < entries.length; i++) {
addEntry(entries[i], out);
}
out.flush();
out.finish();
if (closeStream) {
out.close();
}
}
catch (IOException e) {
throw ZipExceptionUtil.rethrow(e);
}
}
代码示例来源:origin: pxb1988/dex2jar
zos.finish();
代码示例来源:origin: zeroturnaround/zt-zip
/**
* Copies an existing ZIP file and appends it with new entries.
*
* @param zip
* an existing ZIP file (only read).
* @param entries
* new ZIP entries appended.
* @param destOut
* new ZIP destination output stream
*/
public static void addEntries(File zip, ZipEntrySource[] entries, OutputStream destOut) {
if (log.isDebugEnabled()) {
log.debug("Copying '" + zip + "' to a stream and adding " + Arrays.asList(entries) + ".");
}
ZipOutputStream out = null;
try {
out = new ZipOutputStream(destOut);
copyEntries(zip, out);
for (int i = 0; i < entries.length; i++) {
addEntry(entries[i], out);
}
out.finish();
}
catch (IOException e) {
ZipExceptionUtil.rethrow(e);
}
}
代码示例来源:origin: zeroturnaround/zt-zip
/**
* Copies an existing ZIP file and appends it with new entries.
*
* @param is
* an existing ZIP input stream.
* @param entries
* new ZIP entries appended.
* @param destOut
* new ZIP destination output stream
*
* @since 1.9
*/
public static void addEntries(InputStream is, ZipEntrySource[] entries, OutputStream destOut) {
if (log.isDebugEnabled()) {
log.debug("Copying input stream to an output stream and adding " + Arrays.asList(entries) + ".");
}
ZipOutputStream out = null;
try {
out = new ZipOutputStream(destOut);
copyEntries(is, out);
for (int i = 0; i < entries.length; i++) {
addEntry(entries[i], out);
}
out.finish();
}
catch (IOException e) {
ZipExceptionUtil.rethrow(e);
}
}
代码示例来源:origin: zeroturnaround/zt-zip
/**
* Copies an existing ZIP file and transforms the given entries in it.
*
* @param is
* a ZIP input stream.
* @param entries
* ZIP entry transformers.
* @param os
* a ZIP output stream.
* @return <code>true</code> if at least one entry was replaced.
*/
public static boolean transformEntries(InputStream is, ZipEntryTransformerEntry[] entries, OutputStream os) {
if (log.isDebugEnabled())
log.debug("Copying '" + is + "' to '" + os + "' and transforming entries " + Arrays.asList(entries) + ".");
try {
ZipOutputStream out = new ZipOutputStream(os);
TransformerZipEntryCallback action = new TransformerZipEntryCallback(Arrays.asList(entries), out);
iterate(is, action);
// Finishes writing the contents of the ZIP output stream without closing
// the underlying stream.
out.finish();
return action.found();
}
catch (IOException e) {
throw ZipExceptionUtil.rethrow(e);
}
}
代码示例来源:origin: typ0520/fastdex
zipOutputStream.finish();
} catch (IOException e) {
throw new FileUtilException(e);
代码示例来源:origin: typ0520/fastdex
try {
if (zipOutputStream != null) {
zipOutputStream.finish();
zipOutputStream.flush();
zipOutputStream.close();
代码示例来源:origin: zeroturnaround/zt-zip
if (out != null && error == null) {
try {
out.finish();
out.flush();
代码示例来源:origin: apache/nifi
@Override
public void process(final OutputStream rawOut) throws IOException {
try (final OutputStream bufferedOut = new BufferedOutputStream(rawOut);
final ZipOutputStream out = new ZipOutputStream(bufferedOut)) {
out.setLevel(compressionLevel);
for (final FlowFile flowFile : contents) {
final String path = keepPath ? getPath(flowFile) : "";
final String entryName = path + flowFile.getAttribute(CoreAttributes.FILENAME.key());
final ZipEntry zipEntry = new ZipEntry(entryName);
zipEntry.setSize(flowFile.getSize());
try {
out.putNextEntry(zipEntry);
bin.getSession().exportTo(flowFile, out);
out.closeEntry();
unmerged.remove(flowFile);
} catch (ZipException e) {
getLogger().error("Encountered exception merging {}", new Object[] {flowFile}, e);
}
}
out.finish();
out.flush();
}
}
});
代码示例来源:origin: pentaho/pentaho-kettle
zipOutputStream.finish();
zipOutputStream.close();
} catch ( IOException e ) {
代码示例来源:origin: pentaho/pentaho-kettle
if ( zipOutputStream != null ) {
try {
zipOutputStream.finish();
zipOutputStream.close();
} catch ( IOException e ) {
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
/**
* Zip a list of blob.
*
* @param blobs the blob list
* @param fileName if no filename is given, the first blob's filename will be used
* @return a zip containing the list of blob
* @throws IOException
*/
public static Blob zip(List<Blob> blobs, String fileName) throws IOException {
if (fileName == null || (fileName = fileName.trim()).length() == 0) {
fileName = blobs.isEmpty() ? null : blobs.get(0).getFilename();
}
File file = Framework.createTempFile("nxops-createzip-", ".tmp");
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(file));
Framework.trackFile(file, file);
try {
zip(blobs, out);
} finally {
out.finish();
out.close();
}
return Blobs.createBlob(file, "application/zip", null, fileName);
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
/**
* Zip the given blob.
*
* @param blob the blob
* @param filename if no filename is given, the blob's filename will be used
* @return a zip containing the blob
* @throws IOException
*/
public static Blob zip(Blob blob, String filename) throws IOException {
if (filename == null || (filename = filename.trim()).length() == 0) {
filename = blob.getFilename();
}
File file = Framework.createTempFile("nxops-createzip-", ".tmp");
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(file));
Framework.trackFile(file, file);
try {
zip(blob, out);
} finally {
out.finish();
out.close();
}
return Blobs.createBlob(file, "application/zip", null, filename);
}
代码示例来源:origin: apache/opennlp
zip.finish();
zip.flush();
内容来源于网络,如有侵权,请联系作者删除!