import
java.io.*;
import
java.util.Arrays;
import
java.util.zip.DeflaterInputStream;
import
java.util.zip.InflaterOutputStream;
class
InflaterOutputStreamDemo
{
public
static
void
main(String[] args)
throws
IOException
{
byte
b[] = {
1
,
2
,
3
,
4
,
5
,
6
};
ByteArrayInputStream bin =
new
ByteArrayInputStream(b);
DeflaterInputStream din =
new
DeflaterInputStream(bin);
FileOutputStream fos=
new
FileOutputStream(
"file.txt"
);
byte
c[] =
new
byte
[
10
];
din.read(c);
fos.write(c);
din.close();
fos.close();
FileInputStream fis =
new
FileInputStream(
"file.txt"
);
ByteArrayOutputStream bos1=
new
ByteArrayOutputStream();
InflaterOutputStream ios =
new
InflaterOutputStream(bos1);
int
ch;
while
( (ch=fis.read() ) != -
1
)
{
ios.write(ch);
}
System.out.print(Arrays.toString(bos1.toByteArray()));
}
}