|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectWriter
FilterWriter
LineWriter
public class LineWriter
Writes characters to a stream while replacing various EOL by a unique string. This class
catches all occurrences of "\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).
| Field Summary |
|---|
| Fields inherited from class FilterWriter |
|---|
out |
| Fields inherited from class Writer |
|---|
lock |
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class FilterWriter |
|---|
close |
| Methods inherited from class Writer |
|---|
append, append, append, write, write |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public 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.| Method Detail |
|---|
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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||