Interface IHasInputStream

All Known Subinterfaces:
IHasByteArray, IHasInputStreamAndReader, IMemoryReadableResource, IReadableResource, IReadWriteResource, IWrappedReadableResource
All Known Implementing Classes:
AbstractMemoryReadableResource, AbstractWrappedReadableResource, ByteArrayInputStreamProvider, ByteArrayWrapper, ByteBufferInputStreamProvider, CharsetHelper.InputStreamAndCharset, ClassPathResource, FileSystemResource, GZIPReadableResource, HasInputStream, ReadableResourceByteArray, ReadableResourceInputStream, ReadableResourceString, StringInputStreamProvider, URLResource

public interface IHasInputStream
A callback interface to retrieve InputStream objects.
Author:
Philip Helger
  • Method Details

    • getInputStream

      @Nullable InputStream getInputStream()
      Get the input stream to read from the object. Each time this method is called, a new InputStream needs to be created.
      Returns:
      null if resolving failed.
    • getBufferedInputStream

      @Nullable default InputStream getBufferedInputStream()
      Get a buffered input stream to read from the object. Each time this method is called, a new InputStream needs to be created. Internally invokes getInputStream().
      Returns:
      null if resolving failed.
      Since:
      9.1.8
    • withInputStreamDo

      @Nullable default <T> T withInputStreamDo(@Nonnull Function<InputStream,T> aFunc) throws IOException
      Perform something with the InputStream of this object and making sure, that it gets closed correctly afterwards.
      Type Parameters:
      T - The result type of handling the InputStream
      Parameters:
      aFunc - The function to be invoked to read from the InputStream. This function needs to be able to deal with a null-parameter.
      Returns:
      The result of the function. May be null.
      Throws:
      IOException - In case reading from the InputStream fails
      Since:
      11.1.5
    • withBufferedInputStreamDo

      @Nullable default <T> T withBufferedInputStreamDo(@Nonnull Function<InputStream,T> aFunc) throws IOException
      Perform something with the buffered InputStream of this object and making sure, that it gets closed correctly afterwards.
      Type Parameters:
      T - The result type of handling the buffered InputStream
      Parameters:
      aFunc - The function to be invoked to read from the buffered InputStream. This function needs to be able to deal with a null-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 the InputStream from getInputStream() and getBufferedInputStream() can be acquired more than once.
      Returns:
      true if the input stream can be acquired more than once, false if not.