public interface Writable extends Streamable
An interface for classes to implement that are capable of writing themselves to a Writer
Modifier and Type | Method and Description |
---|---|
default void |
writeTo(File file)
|
default void |
writeTo(OutputStream outputStream)
Write this object to the given
OutputStream using StandardCharsets.UTF_8 by default. |
default void |
writeTo(OutputStream outputStream,
Charset charset)
Write this object to the given
OutputStream using StandardCharsets.UTF_8 by default. |
void |
writeTo(Writer out)
Writes this object to the given writer.
|
void writeTo(Writer out) throws IOException
out
- the Writer to which this Writable should output its data.IOException
- if an error occurred while outputting data to the writerdefault void writeTo(OutputStream outputStream) throws IOException
OutputStream
using StandardCharsets.UTF_8
by default.writeTo
in interface Streamable
outputStream
- The output streamIOException
- if an error occurred while outputting data to the writerdefault void writeTo(File file) throws IOException
writeTo
in interface Streamable
file
- The fileIOException
- if an error occurred while outputting data to the writerdefault void writeTo(OutputStream outputStream, @Nullable Charset charset) throws IOException
OutputStream
using StandardCharsets.UTF_8
by default.writeTo
in interface Streamable
outputStream
- The output streamcharset
- The charset to use. Defaults to StandardCharsets.UTF_8
IOException
- if an error occurred while outputting data to the writer