本文整理了Java中org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.flush()
方法的一些代码示例,展示了ZipArchiveOutputStream.flush()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipArchiveOutputStream.flush()
方法的具体详情如下:
包路径:org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
类名称:ZipArchiveOutputStream
方法名:flush
[英]Flushes this output stream and forces any buffered output bytes to be written out to the stream.
[中]刷新此输出流,并强制将任何缓冲输出字节写入流。
代码示例来源:origin: apache/tika
outputStream.flush();
outputStream.closeArchiveEntry();
if (!successfullyCopied) {
outputStream.flush();
outputStream.finish();
outputStream.close();
代码示例来源:origin: USPTO/PatentPublicData
@Override
public void write(byte[] bytes) throws IOException {
Preconditions.checkState(isOpen(), "ZipArchive is not open!");
outputZip.write(bytes);
outputZip.flush();
}
代码示例来源:origin: org.apache.wookie/wookie-parser
/**
* Packages the source file/folder up as a new Zip file
* @param source the source file or folder to be zipped
* @param target the zip file to create
* @throws IOException
*/
public static void repackZip(File source, File target) throws IOException{
ZipArchiveOutputStream out = new ZipArchiveOutputStream(target);
out.setEncoding("UTF-8");
for(File afile: source.listFiles()){
pack(afile,out, "");
}
out.flush();
out.close();
}
代码示例来源:origin: stackoverflow.com
import java.io.*;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
public class ZipFiles {
public static void main(String[] args) throws Exception{
ZipArchiveOutputStream zipOut = new ZipArchiveOutputStream(new FileOutputStream("测试.zip"));
zipOut.setEncoding("Cp437"); // This should handle your "special" characters
zipOut.setFallbackToUTF8(true); // For "unknown" characters!
zipOut.setUseLanguageEncodingFlag(true);
zipOut.setCreateUnicodeExtraFields(
ZipArchiveOutputStream.UnicodeExtraFieldPolicy.NOT_ENCODEABLE);
zipOut.putArchiveEntry(new ZipArchiveEntry("测试.xml"));
zipOut.putArchiveEntry(new ZipArchiveEntry("test.xml"));
zipOut.closeArchiveEntry();
zipOut.flush();
zipOut.close();
}
}
内容来源于网络,如有侵权,请联系作者删除!