summaryrefslogtreecommitdiffstats
path: root/libjava/java/util/zip/DeflaterOutputStream.java
diff options
context:
space:
mode:
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-09 15:22:19 +0000
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-09 15:22:19 +0000
commit9e0c5d3a620e2c00fef805aace78d909b6ed2f33 (patch)
treeda8856033bd84b9270468089c3a2f34c2c565b0a /libjava/java/util/zip/DeflaterOutputStream.java
parent45495fdc0d2ad726ddbafc790713f980fec4a97c (diff)
downloadppe42-gcc-9e0c5d3a620e2c00fef805aace78d909b6ed2f33.tar.gz
ppe42-gcc-9e0c5d3a620e2c00fef805aace78d909b6ed2f33.zip
2004-07-09 Michael Koch <konqueror@gmx.de>
* java/util/zip/DeflaterOutputStream.java, java/util/zip/GZIPInputStream.java, java/util/zip/GZIPOutputStream.java, java/util/zip/InflaterInputStream.java: Reformatted. Added javadocs. Reordered all stuff. Renamed variables to be more clear. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84380 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/util/zip/DeflaterOutputStream.java')
-rw-r--r--libjava/java/util/zip/DeflaterOutputStream.java72
1 files changed, 45 insertions, 27 deletions
diff --git a/libjava/java/util/zip/DeflaterOutputStream.java b/libjava/java/util/zip/DeflaterOutputStream.java
index 6cc3fbf9c23..7ae7d193acd 100644
--- a/libjava/java/util/zip/DeflaterOutputStream.java
+++ b/libjava/java/util/zip/DeflaterOutputStream.java
@@ -60,18 +60,23 @@ import java.io.IOException;
*/
public class DeflaterOutputStream extends FilterOutputStream
{
- public void close () throws IOException
- {
- finish ();
- out.close();
- }
+ /**
+ * This buffer is used temporarily to retrieve the bytes from the
+ * deflater and write them to the underlying output stream.
+ */
+ protected byte[] buf;
+ /**
+ * The deflater which is used to deflate the stream.
+ */
+ protected Deflater def;
+
/**
* Deflates everything in the def's input buffers. This will call
* <code>def.deflate()</code> until all bytes from the input buffers
* are processed.
*/
- protected void deflate () throws IOException
+ protected void deflate() throws IOException
{
do
{
@@ -87,9 +92,9 @@ public class DeflaterOutputStream extends FilterOutputStream
* default buffer size.
* @param out the output stream where deflated output should be written.
*/
- public DeflaterOutputStream (OutputStream out)
+ public DeflaterOutputStream(OutputStream out)
{
- this (out, new Deflater (), 512);
+ this(out, new Deflater(), 512);
}
/**
@@ -98,9 +103,9 @@ public class DeflaterOutputStream extends FilterOutputStream
* @param out the output stream where deflated output should be written.
* @param defl the underlying deflater.
*/
- public DeflaterOutputStream (OutputStream out, Deflater defl)
+ public DeflaterOutputStream(OutputStream out, Deflater defl)
{
- this (out, defl, 512);
+ this(out, defl, 512);
}
/**
@@ -113,7 +118,7 @@ public class DeflaterOutputStream extends FilterOutputStream
*/
public DeflaterOutputStream(OutputStream out, Deflater defl, int bufsize)
{
- super (out);
+ super(out);
if (bufsize <= 0)
throw new IllegalArgumentException("bufsize <= 0");
buf = new byte[bufsize];
@@ -125,11 +130,11 @@ public class DeflaterOutputStream extends FilterOutputStream
* was the only way to ensure that all bytes are flushed in Sun's
* JDK.
*/
- public void finish () throws IOException
+ public void finish() throws IOException
{
inbufWrite();
def.finish();
- while (! def.finished ())
+ while (! def.finished())
{
int len = def.deflate(buf, 0, buf.length);
if (len > 0)
@@ -137,29 +142,48 @@ public class DeflaterOutputStream extends FilterOutputStream
}
}
- public void write (int bval) throws IOException
+ /**
+ * Calls finish() and closes the stream.
+ */
+ public void close() throws IOException
+ {
+ finish();
+ out.close();
+ }
+
+ /**
+ * Writes a single byte to the compressed output stream.
+ * @param bval the byte value.
+ */
+ public void write(int bval) throws IOException
{
if (inbuf == null)
inbuf = new byte[128];
else if (inbufLength == inbuf.length)
- inbufWrite ();
+ inbufWrite();
inbuf[inbufLength++] = (byte) bval;
}
- public void write (byte[] buf, int off, int len) throws IOException
+ /**
+ * Writes a len bytes from an array to the compressed stream.
+ * @param buf the byte array.
+ * @param off the offset into the byte array where to start.
+ * @param len the number of bytes to write.
+ */
+ public void write(byte[] buf, int off, int len) throws IOException
{
- inbufWrite ();
- def.setInput (buf, off, len);
- deflate ();
+ inbufWrite();
+ def.setInput(buf, off, len);
+ deflate();
}
- private void inbufWrite () throws IOException
+ private void inbufWrite() throws IOException
{
if (inbufLength > 0)
{
int size = inbufLength;
inbufLength = 0;
- write (inbuf, 0, size);
+ write(inbuf, 0, size);
}
}
@@ -167,10 +191,4 @@ public class DeflaterOutputStream extends FilterOutputStream
private byte[] inbuf;
// Used length of inbuf.
private int inbufLength;
-
- // The retrieval buffer.
- protected byte[] buf;
-
- // Deflater used to compress data.
- protected Deflater def;
}
OpenPOWER on IntegriCloud