|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.Writer
java.io.FilterWriter
org.geotools.io.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 java.io.FilterWriter |
---|
out |
Fields inherited from class java.io.Writer |
---|
lock |
Constructor Summary | |
---|---|
LineWriter(java.io.Writer out)
Constructs a LineWriter object that will use the platform dependent line separator. |
|
LineWriter(java.io.Writer out,
java.lang.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. |
java.lang.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(java.lang.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(java.lang.String string,
int offset,
int length)
Writes a portion of an array of a string. |
Methods inherited from class java.io.FilterWriter |
---|
close |
Methods inherited from class java.io.Writer |
---|
append, append, append, write, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LineWriter(java.io.Writer out)
LineWriter
object that will use the platform dependent line separator.
out
- A writer object to provide the underlying stream.
java.lang.IllegalArgumentException
- if out
is null
.public LineWriter(java.io.Writer out, java.lang.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.
java.lang.IllegalArgumentException
- if out
or lineSeparator
is null
.Method Detail |
---|
public java.lang.String getLineSeparator()
public void setLineSeparator(java.lang.String lineSeparator)
"\r"
, "\n"
or "\r\n"
.
lineSeparator
- The new line separator.
java.lang.IllegalArgumentException
- If lineSeparator
is null
.public void write(int c) throws java.io.IOException
write
in class java.io.FilterWriter
java.io.IOException
- If an I/O error occurs.public void write(char[] cbuf, int offset, int length) throws java.io.IOException
write
in class java.io.FilterWriter
cbuf
- Buffer of characters to be written.offset
- Offset from which to start reading characters.length
- Number of characters to be written.
java.io.IOException
- If an I/O error occurs.public void write(java.lang.String string, int offset, int length) throws java.io.IOException
write
in class java.io.FilterWriter
string
- String to be written.offset
- Offset from which to start reading characters.length
- Number of characters to be written.
java.io.IOException
- If an I/O error occurs.public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.FilterWriter
java.io.IOException
- If an I/O error occurs.protected boolean isWhitespace(char c) throws java.io.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.
java.io.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 |