Class ByteArrayInputStreamProvider
- java.lang.Object
-
- com.helger.commons.io.streamprovider.ByteArrayInputStreamProvider
-
- All Implemented Interfaces:
IHasByteArray,IHasInputStream,IHasInputStreamAndReader,IHasSize
public class ByteArrayInputStreamProvider extends Object implements IHasByteArray
AnInputStreamprovider based on a byte array.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_COPY_NEEDED
-
Constructor Summary
Constructors Constructor Description ByteArrayInputStreamProvider(byte[] aData)ByteArrayInputStreamProvider(byte[] aData, boolean bCopyNeeded)ByteArrayInputStreamProvider(byte[] aData, int nOfs, int nLen)ByteArrayInputStreamProvider(byte[] aData, int nOfs, int nLen, boolean bCopyNeeded)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]bytes()intgetOffset()booleanisCopy()intsize()StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.commons.io.IHasByteArray
getAllBytes, getBytesAsString, getHexEncoded, getInputStream, hasOffset, isEmpty, isNotEmpty, isReadMultiple, startsWith, writeTo
-
Methods inherited from interface com.helger.commons.io.IHasInputStream
getBufferedInputStream
-
Methods inherited from interface com.helger.commons.io.IHasInputStreamAndReader
getBufferedReader, getReader
-
-
-
-
Field Detail
-
DEFAULT_COPY_NEEDED
public static final boolean DEFAULT_COPY_NEEDED
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ByteArrayInputStreamProvider
public ByteArrayInputStreamProvider(@Nonnull byte[] aData)
-
ByteArrayInputStreamProvider
public ByteArrayInputStreamProvider(@Nonnull byte[] aData, boolean bCopyNeeded)
-
ByteArrayInputStreamProvider
public ByteArrayInputStreamProvider(@Nonnull byte[] aData, @Nonnegative int nOfs, @Nonnegative int nLen)
-
ByteArrayInputStreamProvider
public ByteArrayInputStreamProvider(@Nonnull byte[] aData, @Nonnegative int nOfs, @Nonnegative int nLen, boolean bCopyNeeded)
-
-
Method Detail
-
isCopy
public final boolean isCopy()
- Specified by:
isCopyin interfaceIHasByteArray- Returns:
trueif the contained byte array was copied in the constructor or not.
-
bytes
@Nonnull @ReturnsMutableObject public final byte[] 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:
IHasByteArray.bytes(),IHasSize.size()
-
size
@Nonnegative public final int size()
-
-