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 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

      default @Nullable 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

      default <T> @Nullable 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

      default <T> @Nullable 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.