Class ByteArrayInputStreamProvider
java.lang.Object
com.helger.base.io.streamprovider.ByteArrayInputStreamProvider
- All Implemented Interfaces:
IHasSize,IHasByteArray,IHasInputStream,IHasInputStreamAndReader,IWriteToStream
An
InputStream provider based on a byte array.- Author:
- Philip Helger
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionByteArrayInputStreamProvider(byte @NonNull [] aData) Constructor using the entire byte array without copying.ByteArrayInputStreamProvider(byte @NonNull [] aData, boolean bCopyNeeded) Constructor using the entire byte array.ByteArrayInputStreamProvider(byte @NonNull [] aData, int nOfs, int nLen) Constructor using a portion of the byte array without copying.ByteArrayInputStreamProvider(byte @NonNull [] aData, int nOfs, int nLen, boolean bCopyNeeded) Constructor using a portion of the byte array. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.base.io.iface.IHasByteArray
getAllBytes, getBytesAsString, getHexEncoded, getInputStream, hasOffset, isEmpty, isNotEmpty, isPartialArray, isReadMultiple, startsWith, writeToMethods inherited from interface com.helger.base.io.iface.IHasInputStream
getBufferedInputStream, withBufferedInputStreamDo, withInputStreamDoMethods inherited from interface com.helger.base.io.iface.IHasInputStreamAndReader
getBufferedReader, getReaderMethods inherited from interface com.helger.base.io.iface.IWriteToStream
writeToAndClose
-
Field Details
-
DEFAULT_COPY_NEEDED
public static final boolean DEFAULT_COPY_NEEDED- See Also:
-
-
Constructor Details
-
ByteArrayInputStreamProvider
public ByteArrayInputStreamProvider(byte @NonNull [] aData) Constructor using the entire byte array without copying.- Parameters:
aData- The byte data. May not benull.
-
ByteArrayInputStreamProvider
public ByteArrayInputStreamProvider(byte @NonNull [] aData, boolean bCopyNeeded) Constructor using the entire byte array.- Parameters:
aData- The byte data. May not benull.bCopyNeeded-trueif the data should be copied,falseotherwise.
-
ByteArrayInputStreamProvider
public ByteArrayInputStreamProvider(byte @NonNull [] aData, @Nonnegative int nOfs, @Nonnegative int nLen) Constructor using a portion of the byte array without copying.- Parameters:
aData- The byte data. May not benull.nOfs- Offset into the byte array. Must be ≥ 0.nLen- Length of bytes to use. Must be ≥ 0.
-
ByteArrayInputStreamProvider
public ByteArrayInputStreamProvider(byte @NonNull [] aData, @Nonnegative int nOfs, @Nonnegative int nLen, boolean bCopyNeeded) Constructor using a portion of the byte array.- Parameters:
aData- The byte data. May not benull.nOfs- Offset into the byte array. Must be ≥ 0.nLen- Length of bytes to use. Must be ≥ 0.bCopyNeeded-trueif the data should be copied,falseotherwise.
-
-
Method Details
-
isCopy
public final boolean isCopy()- Specified by:
isCopyin interfaceIHasByteArray- Returns:
trueif the contained byte array was copied in the constructor or not.
-
bytes
@ReturnsMutableObject public final byte @NonNull [] bytes()- Specified by:
bytesin interfaceIHasByteArray- Returns:
- A reference to the contained byte array. Gives write access to the payload! Don't
forget to apply
IHasByteArray.getOffset()andIHasSize.size(). Nevernull.
-
getOffset
@Nonnegative public final int getOffset()- Specified by:
getOffsetin interfaceIHasByteArray- Returns:
- The offset into the byte array to start reading. This is always 0 when copied. Must be ge; 0.
- See Also:
-
size
@Nonnegative public final int size() -
toString
-