- All Superinterfaces:
Appendable
- All Known Implementing Classes:
BufferSimpleWriter
,DefaultSimpleWriter
A simple writer interface.
Similar to a subset from Writer
, but with newLine()
method
added, similar to BufferedWriter.newLine()
but with the difference that
the newline not necessarily uses the line.separator
system property and
instead may target another system.
-
Method Summary
Modifier and TypeMethodDescriptiondefault SimpleWriter
append
(char c) default SimpleWriter
append
(CharSequence csq) default SimpleWriter
append
(CharSequence csq, int start, int end) default char
Get the last character processed.void
newLine()
Write a newline according to the characteristics of the target platform.default void
unwrite()
Remove the last character found in this buffer, if any.default void
unwrite
(int numChars) Remove the lastnumChars
characters found in this buffer.void
write
(char c) Write a character.void
write
(char[] cbuf, int off, int len) Write a sequence of characters from an array.default void
write
(int num) Write an integer.void
write
(CharSequence seq) Write a character sequence.
-
Method Details
-
newLine
Write a newline according to the characteristics of the target platform.- Throws:
IOException
- if an error happens when writing.
-
write
Write a character sequence.- Parameters:
seq
- the CharSequence.- Throws:
IOException
- if an error happens when writing.
-
append
- Specified by:
append
in interfaceAppendable
- Throws:
IOException
-
append
- Specified by:
append
in interfaceAppendable
- Throws:
IOException
-
write
Write a sequence of characters from an array.- Parameters:
cbuf
- the character array.off
- the offset to start writing.len
- the number of characters to write from the array.- Throws:
IOException
- if an error happens when writing.
-
write
Write a character.- Parameters:
c
- the character.- Throws:
IOException
- if an error happens when writing.
-
append
- Specified by:
append
in interfaceAppendable
- Throws:
IOException
-
write
Write an integer.- Parameters:
num
- the integer number.- Throws:
IOException
- if an error happens when writing.
-
unwrite
Remove the last character found in this buffer, if any.Optional operation.
- Throws:
UnsupportedOperationException
- if the operation is not supported.
-
unwrite
Remove the lastnumChars
characters found in this buffer.If
numChars
is larger than the length of this buffer, removes all its contents.- Parameters:
numChars
- the number of characters to remove.- Throws:
UnsupportedOperationException
- if the operation is not supported.
-
getLastChar
Get the last character processed.Optional operation.
- Returns:
- the last character processed.
- Throws:
UnsupportedOperationException
- if the operation is not supported.IllegalStateException
- if no character was processed yet.
-