本文整理了Java中java.util.zip.ZipOutputStream.setMethod()
方法的一些代码示例,展示了ZipOutputStream.setMethod()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipOutputStream.setMethod()
方法的具体详情如下:
包路径:java.util.zip.ZipOutputStream
类名称:ZipOutputStream
方法名:setMethod
[英]Sets the default compression method to be used when a ZipEntry doesn't explicitly specify a method. See ZipEntry#setMethod for more details.
[中]设置ZipEntry未显式指定方法时使用的默认压缩方法。有关更多详细信息,请参见ZipEntry#setMethod。
代码示例来源:origin: iBotPeaches/Apktool
out.setMethod(ZipOutputStream.STORED);
CRC32 crc = new CRC32();
crc.update(data);
代码示例来源:origin: org.apache.ant/ant
output.setMethod(ZipOutputStream.DEFLATED);
output.setLevel(Deflater.DEFAULT_COMPRESSION);
} else {
output.setMethod(ZipOutputStream.STORED);
代码示例来源:origin: ankidroid/Anki-Android
try {
ZipOutputStream z = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(f)));
z.setMethod(ZipOutputStream.DEFLATED);
代码示例来源:origin: pentaho/pentaho-kettle
out.setMethod( ZipOutputStream.DEFLATED );
out.setLevel( Deflater.BEST_COMPRESSION );
代码示例来源:origin: pentaho/pentaho-kettle
out.setMethod( ZipOutputStream.DEFLATED );
代码示例来源:origin: wizzardo/tools
public ZipWriter setMethod(int method) {
out.setMethod(method);
return this;
}
代码示例来源:origin: asakusafw/asakusafw
Writer(OutputStream output) throws IOException {
if (output == null) {
throw new IllegalArgumentException("output must not be null"); //$NON-NLS-1$
}
this.output = new ZipOutputStream(output);
this.output.setMethod(ZipOutputStream.DEFLATED);
this.output.setLevel(0);
this.output.putNextEntry(new ZipEntry(FIRST_ENTRY_NAME));
this.output.closeEntry();
}
代码示例来源:origin: org.databene/databene-commons
public static void compress(File source, File zipFile) throws IOException {
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));
out.setMethod(ZipOutputStream.DEFLATED);
try {
addFileOrDirectory(source, source, out);
out.close();
} catch (IOException e) {
throw new RuntimeException("Zipping the report failed");
}
}
代码示例来源:origin: stackoverflow.com
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(target));
zos.setMethod( ZipOutputStream.DEFLATED );
zos.setLevel( 5 );
...
代码示例来源:origin: stackoverflow.com
// Zip
ZipOutputStream zipOut = ...
zipOut.setMethod(ZipOutputStream.STORED); // No compression.
for(int i = 0; i < tableModel.getRowCount(); i++) {
// Single file
File originalFile = (File) tableModel.getValueAt(i, 0);
FileInputStream originalStream = new FileInputStream(originalFile);
// GZipped single file:
GZipOutputStream gzipOut = ...; ...
// Input of the gzipped thing
InputStream gzipResultIn = ...
// Make a new ZipEntry:
ZipEntry zipEntry = new ZipEntry(originalFile.getName()
+ ".gz.enc");
zipOut.putNextEntry(zipEntry);
encrypt(key, gzipResultIn, zipOut); // Should not close the input
zipOut.closeEntry();
}
zipOut.close();
代码示例来源:origin: org.terracotta/terracotta-ee
public ZipBuilder(File archiveFile, boolean useCompression, boolean verbose) throws IOException {
zout = getArchiveOutputStream(archiveFile);
if (useCompression) {
zout.setMethod(ZipEntry.DEFLATED);
zout.setLevel(9);
} else {
zout.setMethod(ZipEntry.STORED);
zout.setLevel(0);
}
this.verbose = verbose;
}
代码示例来源:origin: org.terracotta/terracotta-l1
public ZipBuilder(File archiveFile, boolean useCompression, boolean verbose) throws IOException {
zout = getArchiveOutputStream(archiveFile);
if (useCompression) {
zout.setMethod(ZipEntry.DEFLATED);
zout.setLevel(9);
} else {
zout.setMethod(ZipEntry.STORED);
zout.setLevel(0);
}
this.verbose = verbose;
}
代码示例来源:origin: diffplug/goomph
/**
* Creates a single-entry zip file.
*
* @param input an uncompressed file
* @param pathWithinArchive the path within the archive
* @param output the new zip file it will be compressed into
*/
public static void zip(File input, String pathWithinArchive, File output) throws IOException {
try (ZipOutputStream zipStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(output)))) {
zipStream.setMethod(ZipOutputStream.DEFLATED);
zipStream.setLevel(9);
zipStream.putNextEntry(new ZipEntry(pathWithinArchive));
try (BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(input))) {
copy(inputStream, zipStream);
}
}
}
代码示例来源:origin: org.terracotta/terracotta-l1-ee
public ZipBuilder(File archiveFile, boolean useCompression, boolean verbose) throws IOException {
zout = getArchiveOutputStream(archiveFile);
if (useCompression) {
zout.setMethod(ZipEntry.DEFLATED);
zout.setLevel(9);
} else {
zout.setMethod(ZipEntry.STORED);
zout.setLevel(0);
}
this.verbose = verbose;
}
代码示例来源:origin: Geomatys/geotoolkit
/**
* Intermediate operation during ip creation
* @param method
* @param level
* @param buf
* @param resources
* @throws IOException
*/
private static void zipCore(int method, int level, BufferedOutputStream buf, Path[] resources) throws IOException {
try (final ZipOutputStream zout = new ZipOutputStream(buf)) {
zout.setMethod(method);
zout.setLevel(level);
zipCore(zout, method, level, "", Arrays.asList(resources).iterator());
}
}
代码示例来源:origin: jasperreports/jasperreports
/**
*
*/
public void zipEntries(OutputStream os) throws IOException
{
ZipOutputStream zipos = new ZipOutputStream(os);
zipos.setMethod(ZipOutputStream.DEFLATED);
for (int i = 0; i < exportZipEntries.size(); i++)
{
ExportZipEntry oasisZipEntry = (ExportZipEntry)exportZipEntries.get(i);
ZipEntry zipEntry = new ZipEntry(oasisZipEntry.getName());
zipos.putNextEntry(zipEntry);
oasisZipEntry.writeData(zipos);
}
zipos.flush();
zipos.finish();
}
代码示例来源:origin: apache/jackrabbit
/**
* @see DefaultHandler#exportData(ExportContext,boolean,Node)
*/
@Override
protected void exportData(ExportContext context, boolean isCollection, Node contentNode) throws IOException, RepositoryException {
ZipOutputStream zout = new ZipOutputStream(context.getOutputStream());
zout.setMethod(ZipOutputStream.DEFLATED);
try {
int pos = contentNode.getPath().length();
exportZipEntry(context, zout, contentNode, pos > 1 ? pos+1 : pos);
} finally {
zout.finish();
}
}
代码示例来源:origin: MCMrARM/revolution-irc
private static void buildThemeZipFile(File zipPath, ResTable resTable) {
try {
FileOutputStream fos = new FileOutputStream(zipPath);
ZipOutputStream outStream = new ZipOutputStream(new BufferedOutputStream(fos));
outStream.setMethod(ZipOutputStream.STORED);
ByteArrayOutputStream byteArrOS = new ByteArrayOutputStream();
ArscWriter writer = new ArscWriter(resTable);
writer.write(byteArrOS);
byte[] bytes = byteArrOS.toByteArray();
ZipEntry entry = new ZipEntry("resources.arsc");
entry.setSize(bytes.length);
CRC32 crc = new CRC32();
crc.update(bytes);
entry.setCrc(crc.getValue());
outStream.putNextEntry(entry);
outStream.write(bytes);
outStream.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
代码示例来源:origin: pentaho/pentaho-reporting
public void writeContent( final ZipEntry entry,
final InputStream in,
final int method,
final int compression ) throws IOException {
zipOutputStream.setMethod( method );
zipOutputStream.setLevel( compression );
zipOutputStream.putNextEntry( entry );
IOUtils.getInstance().copyStreams( in, zipOutputStream );
zipOutputStream.closeEntry();
}
}
代码示例来源:origin: com.github.danny02/Geometrie
@Override
public void writeModel(OutputStream out, Model[] models) throws IOException {
ZipOutputStream zip = new ZipOutputStream(out);
zip.setMethod(ZipOutputStream.STORED);
for (int i = 0; i < models.length; i++) {
ZipEntry zipEntry = new ZipEntry("model" + i + ".ctm");
ByteArrayOutputStream buf = new ByteArrayOutputStream();
writeSingleModel(buf, models[i]);
byte[] toByteArray = buf.toByteArray();
CRC32 c = new CRC32();
c.update(toByteArray);
zipEntry.setSize(toByteArray.length);
zipEntry.setCompressedSize(toByteArray.length);
zipEntry.setCrc(c.getValue());
zip.putNextEntry(zipEntry);
zip.write(toByteArray);
zip.closeEntry();
}
zip.finish();
}
内容来源于网络,如有侵权,请联系作者删除!