public class LineBreaker
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_LINE_LENGTH
The default maximal line length.
|
private java.io.Writer |
destination
The destination writer.
|
private static java.lang.String |
EOL
The system dependent EOL.
|
private int |
lineLength
The current line length.
|
private int |
maxLineLength
The maximal line length.
|
private java.lang.StringBuilder |
word
The string buffer to store the current text.
|
private java.io.BufferedWriter |
writer
The writer to use.
|
| Constructor and Description |
|---|
LineBreaker(java.io.Writer out)
Constructs a new LineBreaker with DEFAULT_MAX_LINE_LENGTH.
|
LineBreaker(java.io.Writer out,
int max)
Constructs a new LineBreaker with the given max line length.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the writer.
|
void |
flush()
Write out the current StringBuilder and flush the writer.
|
java.io.Writer |
getDestination()
Returns the current destination writer.
|
void |
write(java.lang.String text)
Writes the given text to the writer.
|
void |
write(java.lang.String text,
boolean preserveSpace)
Writes the given text to the writer.
|
private void |
writeWord()
Writes the current StringBuilder to the writer.
|
public static final int DEFAULT_MAX_LINE_LENGTH
private static final java.lang.String EOL
private java.io.Writer destination
private java.io.BufferedWriter writer
private int maxLineLength
private int lineLength
private java.lang.StringBuilder word
public LineBreaker(java.io.Writer out)
out - The writer to use.public LineBreaker(java.io.Writer out,
int max)
out - The writer to use.max - The maximal line length.public java.io.Writer getDestination()
public void write(java.lang.String text)
throws java.io.IOException
text - The text to write.java.io.IOException - if there's a problem writing the text.public void write(java.lang.String text,
boolean preserveSpace)
text - The text to write.preserveSpace - True to preserve white space.public void flush()
private void writeWord()
throws java.io.IOException
java.io.IOException - if an exception occurs during writing.public void close()