@@ -54,6 +54,27 @@ import java.util.zip.ZipException;
*/
*/
public class ZipOutputStream extends FilterOutputStream {
public class ZipOutputStream extends FilterOutputStream {
/**
* Compression method for deflated entries.
*
* @since 1.1
*/
public static final int DEFLATED = java.util.zip.ZipEntry.DEFLATED;
/**
* Default compression level for deflated entries.
*
* @since Ant 1.7
*/
public static final int DEFAULT_COMPRESSION = Deflater.DEFAULT_COMPRESSION;
/**
* Compression method for stored entries.
*
* @since 1.1
*/
public static final int STORED = java.util.zip.ZipEntry.STORED;
/**
/**
* Current entry.
* Current entry.
*
*
@@ -73,7 +94,7 @@ public class ZipOutputStream extends FilterOutputStream {
*
*
* @since 1.1
* @since 1.1
*/
*/
private int level = Deflater.D EFAULT_COMPRESSION;
private int level = DEFAULT_COMPRESSION;
/**
/**
* Has the compression level changed when compared to the last
* Has the compression level changed when compared to the last
@@ -182,7 +203,7 @@ public class ZipOutputStream extends FilterOutputStream {
*
*
* @since 1.14
* @since 1.14
*/
*/
protected Deflater def = new Deflater(Deflater.DEFAULT_COMPRESSION , true);
protected Deflater def = new Deflater(level , true);
/**
/**
* This buffer servers as a Deflater.
* This buffer servers as a Deflater.
@@ -203,20 +224,6 @@ public class ZipOutputStream extends FilterOutputStream {
*/
*/
private RandomAccessFile raf = null;
private RandomAccessFile raf = null;
/**
* Compression method for deflated entries.
*
* @since 1.1
*/
public static final int DEFLATED = java.util.zip.ZipEntry.DEFLATED;
/**
* Compression method for stored entries.
*
* @since 1.1
*/
public static final int STORED = java.util.zip.ZipEntry.STORED;
/**
/**
* Creates a new ZIP OutputStream filtering the underlying stream.
* Creates a new ZIP OutputStream filtering the underlying stream.
* @param out the outputstream to zip
* @param out the outputstream to zip
@@ -430,10 +437,16 @@ public class ZipOutputStream extends FilterOutputStream {
* Sets the compression level for subsequent entries.
* Sets the compression level for subsequent entries.
*
*
* <p>Default is Deflater.DEFAULT_COMPRESSION.</p>
* <p>Default is Deflater.DEFAULT_COMPRESSION.</p>
* @param level the compression level
* @param level the compression level.
* @throws IllegalArgumentException if an invalid compression level is specified.
* @since 1.1
* @since 1.1
*/
*/
public void setLevel(int level) {
public void setLevel(int level) {
if (level < Deflater.DEFAULT_COMPRESSION
|| level > Deflater.BEST_COMPRESSION) {
throw new IllegalArgumentException(
"Invalid compression level: " + level);
}
hasCompressionLevelChanged = (this.level != level);
hasCompressionLevelChanged = (this.level != level);
this.level = level;
this.level = level;
}
}
@@ -843,7 +856,7 @@ public class ZipOutputStream extends FilterOutputStream {
*
*
* @since 1.14
* @since 1.14
*/
*/
protected final void writeOut(byte [] data) throws IOException {
protected final void writeOut(byte[] data) throws IOException {
writeOut(data, 0, data.length);
writeOut(data, 0, data.length);
}
}
@@ -856,7 +869,7 @@ public class ZipOutputStream extends FilterOutputStream {
*
*
* @since 1.14
* @since 1.14
*/
*/
protected final void writeOut(byte [] data, int offset, int length)
protected final void writeOut(byte[] data, int offset, int length)
throws IOException {
throws IOException {
if (raf != null) {
if (raf != null) {
raf.write(data, offset, length);
raf.write(data, offset, length);