All Known Implementing Classes:
InspectedContent, Layer

public interface Content
Content with a known size that can be written to an OutputStream.
Since:
2.3.0
Author:
Phillip Webb
  • Method Summary

    Modifier and Type
    Method
    Description
    static Content
    of(byte[] bytes)
    Create a new Content from the given input stream.
    static Content
    of(int size, IOSupplier<InputStream> supplier)
    Create a new Content from the given input stream.
    static Content
    of(File file)
    Create a new Content from the given file.
    static Content
    of(String string)
    Create a new Content from the given UTF-8 string.
    int
    The size of the content in bytes.
    void
    writeTo(OutputStream outputStream)
    Write the content to the given output stream.
  • Method Details

    • size

      int size()
      The size of the content in bytes.
      Returns:
      the content size
    • writeTo

      void writeTo(OutputStream outputStream) throws IOException
      Write the content to the given output stream.
      Parameters:
      outputStream - the output stream to write to
      Throws:
      IOException - on IO error
    • of

      static Content of(String string)
      Create a new Content from the given UTF-8 string.
      Parameters:
      string - the string to write
      Returns:
      a new Content instance
    • of

      static Content of(byte[] bytes)
      Create a new Content from the given input stream.
      Parameters:
      bytes - the bytes to write
      Returns:
      a new Content instance
    • of

      static Content of(File file)
      Create a new Content from the given file.
      Parameters:
      file - the file to write
      Returns:
      a new Content instance
    • of

      static Content of(int size, IOSupplier<InputStream> supplier)
      Create a new Content from the given input stream. The stream will be closed after it has been written.
      Parameters:
      size - the size of the supplied input stream
      supplier - the input stream supplier
      Returns:
      a new Content instance