Package com.helger.commons.io.stream
Class HasInputStream
- java.lang.Object
-
- com.helger.commons.io.stream.HasInputStream
-
- All Implemented Interfaces:
IHasInputStream
@Immutable public class HasInputStream extends Object implements IHasInputStream
Special implementation ofIHasInputStreamwith that has an InputStream supplier that can be read more than once!- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description HasInputStream(Supplier<? extends InputStream> aISP, boolean bReadMultiple)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static IHasInputStreamcreate(NonBlockingByteArrayOutputStream aBAOS)Get a special implementation ofIHasInputStreamforNonBlockingByteArrayOutputStream.InputStreamgetInputStream()Get the input stream to read from the object.booleanisReadMultiple()Check if theInputStreamfromIHasInputStream.getInputStream()andIHasInputStream.getBufferedInputStream()can be acquired more than once.static HasInputStreammultiple(Supplier<? extends InputStream> aISP)Create a new object with a supplier that can read multiple times.static HasInputStreamonce(Supplier<? extends InputStream> aISP)Create a new object with a supplier that can be read only once.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.IHasInputStream
getBufferedInputStream
-
-
-
-
Constructor Detail
-
HasInputStream
public HasInputStream(@Nonnull Supplier<? extends InputStream> aISP, boolean bReadMultiple)
Constructor- Parameters:
aISP-InputStreamsupplier. May not benull.bReadMultiple-trueif the supplier can be invoked more than once (e.g. from a byte[]) orfalseif it can be invoked only once (e.g. from an open socket).
-
-
Method Detail
-
isReadMultiple
public final boolean isReadMultiple()
Description copied from interface:IHasInputStreamCheck if theInputStreamfromIHasInputStream.getInputStream()andIHasInputStream.getBufferedInputStream()can be acquired more than once.- Specified by:
isReadMultiplein interfaceIHasInputStream- Returns:
trueif the input stream can be acquired more than once,falseif not.
-
getInputStream
public final InputStream getInputStream()
Description copied from interface:IHasInputStreamGet the input stream to read from the object. Each time this method is called, a newInputStreamneeds to be created.- Specified by:
getInputStreamin interfaceIHasInputStream- Returns:
nullif resolving failed.
-
multiple
@Nonnull @ReturnsMutableCopy public static HasInputStream multiple(@Nonnull Supplier<? extends InputStream> aISP)
Create a new object with a supplier that can read multiple times.- Parameters:
aISP-InputStreamprovider. May not benull.- Returns:
- Never
null.
-
once
@Nonnull @ReturnsMutableCopy public static HasInputStream once(@Nonnull Supplier<? extends InputStream> aISP)
Create a new object with a supplier that can be read only once.- Parameters:
aISP-InputStreamprovider. May not benull.- Returns:
- Never
null.
-
create
@Nonnull @ReturnsMutableCopy public static IHasInputStream create(@Nonnull NonBlockingByteArrayOutputStream aBAOS)
Get a special implementation ofIHasInputStreamforNonBlockingByteArrayOutputStream. This input stream can be read multiple times.- Parameters:
aBAOS- Source stream. May not benull.- Returns:
- Never
null. - Since:
- 9.2.1
-
-