java.lang.Object
java.io.InputStream
org.omnifaces.resourcehandler.CombinedResourceInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
This InputStream
implementation takes care that all in the constructor given resources are been read in
sequence.
- Author:
- Bauke Scholtz
-
Constructor Summary
ConstructorsConstructorDescriptionCombinedResourceInputStream
(Set<Resource> resources) Creates an instance ofCombinedResourceInputStream
based on the given resources. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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, skipNBytes, transferTo
-
Constructor Details
-
CombinedResourceInputStream
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 Details
-
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
.- Specified by:
read
in classInputStream
- Throws:
IOException
-
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
.- Overrides:
read
in classInputStream
- Throws:
IOException
-
close
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
-