Package org.greenrobot.essentials.io
Class PipelineOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.greenrobot.essentials.io.PipelineOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class PipelineOutputStream extends java.io.OutputStreamReplacement for Java's PipedOutputStream: all data written to this stream will get available in the integrated InputStream (seegetInputStream()). Note: Usually, you will have exactly two threads: one to write and one to read. If you use a single thread, avoid reading more bytes than previously written or writing more bytes than the internal buffer can handle.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classPipelineOutputStream.PipelineInputStream
-
Field Summary
Fields Modifier and Type Field Description (package private) CircularByteBufferbuffer(package private) booleanclosedIn(package private) booleanclosedOutprivate PipelineOutputStream.PipelineInputStreaminputStream
-
Constructor Summary
Constructors Constructor Description PipelineOutputStream()PipelineOutputStream(int bufferCapacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckPipelineInput()voidclose()java.io.InputStreamgetInputStream()(package private) voidnotifyBuffer()(package private) voidwaitForBuffer()voidwrite(byte[] data, int off, int len)voidwrite(int b)
-
-
-
Field Detail
-
inputStream
private final PipelineOutputStream.PipelineInputStream inputStream
-
buffer
final CircularByteBuffer buffer
-
closedOut
boolean closedOut
-
closedIn
boolean closedIn
-
-
Method Detail
-
getInputStream
public java.io.InputStream getInputStream()
-
write
public void write(byte[] data, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
checkPipelineInput
private void checkPipelineInput() throws java.io.IOException- Throws:
java.io.IOException
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
waitForBuffer
void waitForBuffer() throws java.io.IOException- Throws:
java.io.IOException
-
notifyBuffer
void notifyBuffer()
-
-