Package de.pdark.decentxml
Class JoinedInputStream
java.lang.Object
java.io.InputStream
de.pdark.decentxml.JoinedInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
This class allows to join several
InputStream
's into one.
Reading from an instance of JoinedInputStream
will
read each underlying InputStream
until it is
depleted and then continue with the next one.
Depleted InputStream
's will be closed as soon
as possible.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(InputStream in) Add anotherInputStream
.void
close()
private void
Remove the currentInputStream
and close it.int
read()
int
read
(byte[] b, int off, int len) Methods inherited from class java.io.InputStream
available, mark, markSupported, read, reset, skip
-
Field Details
-
streams
-
-
Constructor Details
-
JoinedInputStream
public JoinedInputStream()
-
-
Method Details
-
add
Add anotherInputStream
.It is allowed to add more
InputStream
's even after reading has started.It is illegal to add more streams after the joined stream has been closed.
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
popStream
Remove the currentInputStream
and close it.- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-