1 | /*
|
---|
2 | * FinishableWrapperOutputStream
|
---|
3 | *
|
---|
4 | * Author: Lasse Collin <lasse.collin@tukaani.org>
|
---|
5 | *
|
---|
6 | * This file has been put into the public domain.
|
---|
7 | * You can do whatever you want with this file.
|
---|
8 | */
|
---|
9 |
|
---|
10 | package org.tukaani.xz;
|
---|
11 |
|
---|
12 | import java.io.OutputStream;
|
---|
13 | import java.io.IOException;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Wraps an output stream to a finishable output stream for use with
|
---|
17 | * raw encoders. This is not needed for XZ compression and thus most
|
---|
18 | * people will never need this.
|
---|
19 | */
|
---|
20 | public class FinishableWrapperOutputStream extends FinishableOutputStream {
|
---|
21 | /**
|
---|
22 | * The {@link java.io.OutputStream OutputStream} that has been
|
---|
23 | * wrapped into a FinishableWrapperOutputStream.
|
---|
24 | */
|
---|
25 | protected OutputStream out;
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * Creates a new output stream which support finishing.
|
---|
29 | * The <code>finish()</code> method will do nothing.
|
---|
30 | */
|
---|
31 | public FinishableWrapperOutputStream(OutputStream out) {
|
---|
32 | this.out = out;
|
---|
33 | }
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Calls {@link java.io.OutputStream#write(int) out.write(b)}.
|
---|
37 | */
|
---|
38 | public void write(int b) throws IOException {
|
---|
39 | out.write(b);
|
---|
40 | }
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * Calls {@link java.io.OutputStream#write(byte[]) out.write(buf)}.
|
---|
44 | */
|
---|
45 | public void write(byte[] buf) throws IOException {
|
---|
46 | out.write(buf);
|
---|
47 | }
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * Calls {@link java.io.OutputStream#write(byte[],int,int)
|
---|
51 | out.write(buf, off, len)}.
|
---|
52 | */
|
---|
53 | public void write(byte[] buf, int off, int len) throws IOException {
|
---|
54 | out.write(buf, off, len);
|
---|
55 | }
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Calls {@link java.io.OutputStream#flush() out.flush()}.
|
---|
59 | */
|
---|
60 | public void flush() throws IOException {
|
---|
61 | out.flush();
|
---|
62 | }
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Calls {@link java.io.OutputStream#close() out.close()}.
|
---|
66 | */
|
---|
67 | public void close() throws IOException {
|
---|
68 | out.close();
|
---|
69 | }
|
---|
70 | }
|
---|