MCPcopy Create free account
hub / github.com/davidgiven/luje / FilterOutputStream

Class FilterOutputStream

lib/java/io/FilterOutputStream.java:33–154  ·  view source on GitHub ↗

Wraps an existing OutputStream and performs some transformation on the output data while it is being written. Transformations can be anything from a simple byte-wise filtering output data to an on-the-fly compression or decompression of the underlying stream. Output streams that wrap another

Source from the content-addressed store, hash-verified

31 * @see FilterOutputStream
32 */
33public class FilterOutputStream extends OutputStream {
34
35 /**
36 * The target output stream for this filter stream.
37 */
38 protected OutputStream out;
39
40 /**
41 * Constructs a new {@code FilterOutputStream} with {@code out} as its
42 * target stream.
43 *
44 * @param out
45 * the target stream that this stream writes to.
46 */
47 public FilterOutputStream(OutputStream out) {
48 this.out = out;
49 }
50
51 /**
52 * Closes this stream. This implementation closes the target stream.
53 *
54 * @throws IOException
55 * if an error occurs attempting to close this stream.
56 */
57 @Override
58 public void close() throws IOException {
59 Throwable thrown = null;
60 try {
61 flush();
62 } catch (Throwable e) {
63 thrown = e;
64 }
65
66 try {
67 out.close();
68 } catch (Throwable e) {
69 if (thrown == null) {
70 thrown = e;
71 }
72 }
73
74 if (thrown != null) {
75 SneakyThrow.sneakyThrow(thrown);
76 }
77 }
78
79 /**
80 * Ensures that all pending data is sent out to the target stream. This
81 * implementation flushes the target stream.
82 *
83 * @throws IOException
84 * if an error occurs attempting to flush this stream.
85 */
86 @Override
87 public void flush() throws IOException {
88 out.flush();
89 }
90

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected