- java.lang.Object
-
- java.io.InputStream
-
- org.omnifaces.resourcehandler.CombinedResourceInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public final class CombinedResourceInputStream extends InputStream
This
InputStream
implementation takes care that all in the constructor given resources are been read in sequence.- Author:
- Bauke Scholtz
-
-
Constructor Summary
Constructors Constructor Description CombinedResourceInputStream(Set<Resource> resources)
Creates an instance ofCombinedResourceInputStream
based on the given resources.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes theInputStream
of each resource.int
read()
For each resource, read until itsInputStream.read()
returns-1
and then iterate to theInputStream
of the next resource, if any available, else return-1
.int
read(byte[] b, int offset, int length)
For each resource, read until itsInputStream.read()
returns-1
and then iterate to theInputStream
of the next resource, if any available, else return-1
.-
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
-
-
-
Constructor Detail
-
CombinedResourceInputStream
public CombinedResourceInputStream(Set<Resource> resources) throws IOException
Creates an instance ofCombinedResourceInputStream
based on the given resources. For each resource, theInputStream
will be obtained and hold in an iterable collection.- Parameters:
resources
- The resources to be read.- Throws:
IOException
- If something fails at I/O level.
-
-
Method Detail
-
read
public int read() throws IOException
For each resource, read until itsInputStream.read()
returns-1
and then iterate to theInputStream
of the next resource, if any available, else return-1
.- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] b, int offset, int length) throws IOException
For each resource, read until itsInputStream.read()
returns-1
and then iterate to theInputStream
of the next resource, if any available, else return-1
.- Overrides:
read
in classInputStream
- Throws:
IOException
-
close
public void close() throws IOException
Closes theInputStream
of each resource. Whenever theInputStream.close()
throws anIOException
for the first time, it will be caught and be thrown after all resources have been closed. AnyIOException
which is thrown by a subsequent close will be ignored by design.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
-