Package com.helger.base.io.iface
Interface IHasInputStream
- All Known Subinterfaces:
IHasByteArray,IHasInputStreamAndReader
- All Known Implementing Classes:
ByteArrayInputStreamProvider,ByteArrayWrapper,ByteBufferInputStreamProvider,CharsetHelper.InputStreamAndCharset,HasInputStream,StringInputStreamProvider
public interface IHasInputStream
A callback interface to retrieve
InputStream objects.- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable InputStreamGet a buffered input stream to read from the object.@Nullable InputStreamGet the input stream to read from the object.booleanCheck if theInputStreamfromgetInputStream()andgetBufferedInputStream()can be acquired more than once.default <T> @Nullable TwithBufferedInputStreamDo(@NonNull Function<InputStream, T> aFunc) Perform something with the bufferedInputStreamof this object and making sure, that it gets closed correctly afterwards.default <T> @Nullable TwithInputStreamDo(@NonNull Function<InputStream, T> aFunc) Perform something with theInputStreamof this object and making sure, that it gets closed correctly afterwards.
-
Method Details
-
getInputStream
@Nullable InputStream getInputStream()Get the input stream to read from the object. Each time this method is called, a newInputStreamneeds to be created.- Returns:
nullif resolving failed.
-
getBufferedInputStream
Get a buffered input stream to read from the object. Each time this method is called, a newInputStreamneeds to be created. Internally invokesgetInputStream().- Returns:
nullif resolving failed.- Since:
- 9.1.8
-
withInputStreamDo
default <T> @Nullable T withInputStreamDo(@NonNull Function<InputStream, T> aFunc) throws IOExceptionPerform something with theInputStreamof this object and making sure, that it gets closed correctly afterwards.- Type Parameters:
T- The result type of handling theInputStream- Parameters:
aFunc- The function to be invoked to read from theInputStream. This function needs to be able to deal with anull-parameter.- Returns:
- The result of the function. May be
null. - Throws:
IOException- In case reading from the InputStream fails- Since:
- 11.1.5
-
withBufferedInputStreamDo
default <T> @Nullable T withBufferedInputStreamDo(@NonNull Function<InputStream, T> aFunc) throws IOExceptionPerform something with the bufferedInputStreamof this object and making sure, that it gets closed correctly afterwards.- Type Parameters:
T- The result type of handling the bufferedInputStream- Parameters:
aFunc- The function to be invoked to read from the bufferedInputStream. This function needs to be able to deal with anull-parameter.- Returns:
- The result of the function. May be
null. - Throws:
IOException- In case reading from the InputStream fails- Since:
- 11.1.5
-
isReadMultiple
boolean isReadMultiple()Check if theInputStreamfromgetInputStream()andgetBufferedInputStream()can be acquired more than once.- Returns:
trueif the input stream can be acquired more than once,falseif not.
-