- java.lang.Object
-
- java.io.InputStream
-
- org.omnifaces.resourcehandler.CombinedResourceInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class CombinedResourceInputStream extends InputStream
This
InputStreamimplementation 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 ofCombinedResourceInputStreambased on the given resources.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes theInputStreamof each resource.intread()For each resource, read until itsInputStream.read()returns-1and then iterate to theInputStreamof the next resource, if any available, else return-1.intread(byte[] b, int offset, int length)For each resource, read until itsInputStream.read()returns-1and then iterate to theInputStreamof 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 ofCombinedResourceInputStreambased on the given resources. For each resource, theInputStreamwill 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 IOExceptionFor each resource, read until itsInputStream.read()returns-1and then iterate to theInputStreamof the next resource, if any available, else return-1.- Specified by:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] b, int offset, int length) throws IOExceptionFor each resource, read until itsInputStream.read()returns-1and then iterate to theInputStreamof the next resource, if any available, else return-1.- Overrides:
readin classInputStream- Throws:
IOException
-
close
public void close() throws IOExceptionCloses theInputStreamof each resource. Whenever theInputStream.close()throws anIOExceptionfor the first time, it will be caught and be thrown after all resources have been closed. AnyIOExceptionwhich is thrown by a subsequent close will be ignored by design.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
-