public class LineWriter extends FilterWriter
"\r", "\n" and "\r\n", and replaces them by the
platform depend EOL string ("\r\n" on Windows, "\n" on Unix), or any other EOL
explicitly set at construction time. This writer also remove trailing blanks before end of lines,
but this behavior can be changed by overriding isWhitespace(char).out| Constructor and Description |
|---|
LineWriter(Writer out)
Constructs a
LineWriter object that will use the platform dependent line separator. |
LineWriter(Writer out,
String lineSeparator)
Constructs a
LineWriter object that will use the specified line separator. |
| Modifier and Type | Method and Description |
|---|---|
void |
flush()
Flushs the stream's content to the underlying stream.
|
String |
getLineSeparator()
Returns the current line separator.
|
protected boolean |
isWhitespace(char c)
Returns
true if the specified character is a white space that can be ignored on end
of line. |
void |
setLineSeparator(String lineSeparator)
Changes the line separator.
|
void |
write(char[] cbuf,
int offset,
int length)
Writes a portion of an array of characters.
|
void |
write(int c)
Writes a single character.
|
void |
write(String string,
int offset,
int length)
Writes a portion of an array of a string.
|
closepublic LineWriter(Writer out)
LineWriter object that will use the platform dependent line separator.out - A writer object to provide the underlying stream.IllegalArgumentException - if out is null.public LineWriter(Writer out, String lineSeparator)
LineWriter object that will use the specified line separator.out - A writer object to provide the underlying stream.lineSeparator - String to use as line separator.IllegalArgumentException - if out or lineSeparator is null.public String getLineSeparator()
public void setLineSeparator(String lineSeparator)
"\r", "\n" or "\r\n".lineSeparator - The new line separator.IllegalArgumentException - If lineSeparator is null.public void write(int c)
throws IOException
write in class FilterWriterIOException - If an I/O error occurs.public void write(char[] cbuf,
int offset,
int length)
throws IOException
write in class FilterWritercbuf - Buffer of characters to be written.offset - Offset from which to start reading characters.length - Number of characters to be written.IOException - If an I/O error occurs.public void write(String string, int offset, int length) throws IOException
write in class FilterWriterstring - String to be written.offset - Offset from which to start reading characters.length - Number of characters to be written.IOException - If an I/O error occurs.public void flush()
throws IOException
flush in interface Flushableflush in class FilterWriterIOException - If an I/O error occurs.protected boolean isWhitespace(char c)
throws IOException
true if the specified character is a white space that can be ignored on end
of line. The default implementation returns Character.isSpaceChar(char). Subclasses
can override this method in order to change the criterion.c - The character to test.true if c is a character that can be ignored on end of line.IOException - if this method can not determine if the character is ignoreable.Copyright © 1996–2019 Geotools. All rights reserved.