- java.lang.Object
-
- java.io.OutputStream
-
- net.morimekta.io.sub.TerminatedOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
public class TerminatedOutputStream extends OutputStream
A wrapping output stream that writes a terminating byte when closing the stream. It is meant to be paired with aTerminatedInputStream
, which will terminate the wrapping stream as it at end of content when the terminating byte is read.Note that the input behavior will be faulty if the terminating byte is written to the output stream.
-
-
Constructor Summary
Constructors Constructor Description TerminatedOutputStream(OutputStream out)
TerminatedOutputStream(OutputStream out, int terminator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
void
write(byte[] b, int off, int len)
void
write(int i)
-
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
-
-
-
Constructor Detail
-
TerminatedOutputStream
public TerminatedOutputStream(OutputStream out)
-
TerminatedOutputStream
public TerminatedOutputStream(OutputStream out, int terminator)
-
-
Method Detail
-
write
public void write(int i) throws IOException
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
-