Class ByteSource
- java.lang.Object
-
- com.epam.reportportal.utils.files.ByteSource
-
- Direct Known Subclasses:
TypeAwareByteSource
public class ByteSource extends java.lang.ObjectA readable stateful source of bytes. Use it as supplier for InputStreams.
-
-
Constructor Summary
Constructors Constructor Description ByteSource(ByteSource source)ByteSource(java.net.URL sourceUrl)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStreamopenBufferedStream()Wrap resultInputStreamobject intoBufferedInputStreamobject.java.io.InputStreamopenStream()Return newInputStreamobject which can be read and closed naturally.byte[]read()Read internal byte source and return it as byte array.static ByteSourcewrap(byte[] source)Create an instance of the object from given bytes.
-
-
-
Constructor Detail
-
ByteSource
public ByteSource(@Nonnull ByteSource source)
-
ByteSource
public ByteSource(@Nonnull java.net.URL sourceUrl)
-
-
Method Detail
-
wrap
@Nonnull public static ByteSource wrap(@Nonnull byte[] source)
Create an instance of the object from given bytes.- Parameters:
source- bytes to use to create the instance- Returns:
- current class instance
-
openStream
@Nonnull public java.io.InputStream openStream() throws java.io.IOExceptionReturn newInputStreamobject which can be read and closed naturally.- Returns:
- stream
- Throws:
java.io.IOException- reading error or null byte source
-
openBufferedStream
@Nonnull public java.io.InputStream openBufferedStream() throws java.io.IOExceptionWrap resultInputStreamobject intoBufferedInputStreamobject.- Returns:
- buffered stream
- Throws:
java.io.IOException- reading error or null byte source
-
read
@Nonnull public byte[] read() throws java.io.IOExceptionRead internal byte source and return it as byte array. The result will be cached if not cached already.- Returns:
- read data
- Throws:
java.io.IOException- reading error or null byte source
-
-