Interface Writable

  • All Superinterfaces:
    Streamable

    public interface Writable
    extends Streamable

    An interface for classes to implement that are capable of writing themselves to a Writer

    .
    Since:
    1.0
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default void writeTo​(java.io.File file)
      Write this Writable to the given File.
      default void writeTo​(java.io.OutputStream outputStream)
      Write this object to the given OutputStream using StandardCharsets.UTF_8 by default.
      default void writeTo​(java.io.OutputStream outputStream, java.nio.charset.Charset charset)
      Write this object to the given OutputStream using StandardCharsets.UTF_8 by default.
      void writeTo​(java.io.Writer out)
      Writes this object to the given writer.
    • Method Detail

      • writeTo

        void writeTo​(java.io.Writer out)
              throws java.io.IOException
        Writes this object to the given writer.
        Parameters:
        out - the Writer to which this Writable should output its data.
        Throws:
        java.io.IOException - if an error occurred while outputting data to the writer
      • writeTo

        default void writeTo​(java.io.OutputStream outputStream)
                      throws java.io.IOException
        Write this object to the given OutputStream using StandardCharsets.UTF_8 by default.
        Specified by:
        writeTo in interface Streamable
        Parameters:
        outputStream - The output stream
        Throws:
        java.io.IOException - if an error occurred while outputting data to the writer
      • writeTo

        default void writeTo​(java.io.File file)
                      throws java.io.IOException
        Write this Writable to the given File.
        Specified by:
        writeTo in interface Streamable
        Parameters:
        file - The file
        Throws:
        java.io.IOException - if an error occurred while outputting data to the writer
      • writeTo

        default void writeTo​(java.io.OutputStream outputStream,
                             @Nullable
                             java.nio.charset.Charset charset)
                      throws java.io.IOException
        Write this object to the given OutputStream using StandardCharsets.UTF_8 by default.
        Specified by:
        writeTo in interface Streamable
        Parameters:
        outputStream - The output stream
        charset - The charset to use. Defaults to StandardCharsets.UTF_8
        Throws:
        java.io.IOException - if an error occurred while outputting data to the writer