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.OutputStream
Replacement 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 class
PipelineOutputStream.PipelineInputStream
-
Field Summary
Fields Modifier and Type Field Description (package private) CircularByteBuffer
buffer
(package private) boolean
closedIn
(package private) boolean
closedOut
private PipelineOutputStream.PipelineInputStream
inputStream
-
Constructor Summary
Constructors Constructor Description PipelineOutputStream()
PipelineOutputStream(int bufferCapacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkPipelineInput()
void
close()
java.io.InputStream
getInputStream()
(package private) void
notifyBuffer()
(package private) void
waitForBuffer()
void
write(byte[] data, int off, int len)
void
write(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:
write
in 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:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
waitForBuffer
void waitForBuffer() throws java.io.IOException
- Throws:
java.io.IOException
-
notifyBuffer
void notifyBuffer()
-
-