-
Notifications
You must be signed in to change notification settings - Fork 20
/
UncloseableOutputStream.java
56 lines (46 loc) · 1.3 KB
/
UncloseableOutputStream.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - [email protected]
*/
package sirius.kernel.commons;
import java.io.IOException;
import java.io.OutputStream;
/**
* Wraps a given <tt>OutputStream</tt> and blocks every call to {@link #close()}.
* <p>
* Note that instead of {@link #close()}, we call {@link #flush()} on the underlying stream.
*/
public class UncloseableOutputStream extends OutputStream {
private final OutputStream delegate;
/**
* Creates a new instance which wraps the given delegate.
*
* @param delegate the stream to delegate all method calls to, except for <tt>close</tt>
*/
public UncloseableOutputStream(OutputStream delegate) {
this.delegate = delegate;
}
@Override
public void write(int b) throws IOException {
delegate.write(b);
}
@Override
public void write(byte[] b) throws IOException {
delegate.write(b);
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
delegate.write(b, off, len);
}
@Override
public void flush() throws IOException {
delegate.flush();
}
@Override
public void close() throws IOException {
delegate.flush();
}
}