public class CompressionSwitchingOutputStream
extends java.io.FilterOutputStream
Since compression is block-oriented, this is tricky and doesn't support a lot of things (e.g. marking). Also, be aware that just using this and rapidly toggling compression may not actually help, since compression is best done on large amounts of data. Also, compression costs CPU so way the CPU vs. I/O benefit tradeoff, especially for server-side applications.
Copyright 2000-2014 Partner Software, Inc.
| Constructor and Description |
|---|
CompressionSwitchingOutputStream(java.io.OutputStream out,
int compressionLevel)
Create a new CompressionSwitchingOutputStream wrapping
the given OutputStream and set at the given compression level.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
int |
getCompressionLevel()
Get the current compression level.
|
boolean |
isCompressing()
Get whether stream is currently compressing.
|
void |
setCompressing(boolean tizit)
Set whether stream is currently compressing.
|
void |
setCompressionLevel(int newLevel)
Set the current compression level.
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int byteMe) |
public CompressionSwitchingOutputStream(java.io.OutputStream out,
int compressionLevel)
out - output stream to send compressed data overcompressionLevel - level of compression from 0 to 9public void write(int byteMe)
throws java.io.IOException
write in class java.io.FilterOutputStreamjava.io.IOExceptionpublic void write(byte[] b)
throws java.io.IOException
write in class java.io.FilterOutputStreamjava.io.IOExceptionpublic void write(byte[] b,
int off,
int len)
throws java.io.IOException
write in class java.io.FilterOutputStreamjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.FilterOutputStreamjava.io.IOExceptionpublic boolean isCompressing()
public void setCompressing(boolean tizit)
throws java.io.IOException
tizit - whether to turn on compression or turn it offjava.io.IOException - if it couldn't make the changepublic int getCompressionLevel()
public void setCompressionLevel(int newLevel)
newLevel - new compression level