org.geotools.io
Class LineWriter

java.lang.Object
  extended byjava.io.Writer
      extended byjava.io.FilterWriter
          extended byorg.geotools.io.LineWriter

public class LineWriter
extends java.io.FilterWriter

Write characters to a stream while replacing various EOL by a unique string. This class catch all occurrences of "\r", "\n" and "\r\n", and replace 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.

Since:
2.0
Version:
$Id: LineWriter.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux

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)
          Construct a object that will use the platform dependent line separator.
LineWriter(java.io.Writer out, java.lang.String lineSeparator)
          Construct a object that will use the specified line separator.
 
Method Summary
 void flush()
          Flush the stream's content to the underlying stream.
 java.lang.String getLineSeparator()
          Returns the current line separator.
 void setLineSeparator(java.lang.String lineSeparator)
          Change the line separator.
 void write(char[] cbuf, int offset, int length)
          Write a portion of an array of characters.
 void write(int c)
          Write a single character.
 void write(java.lang.String string, int offset, int length)
          Write a portion of an array of a string.
 
Methods inherited from class java.io.FilterWriter
close
 
Methods inherited from class java.io.Writer
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineWriter

public LineWriter(java.io.Writer out)
Construct a object that will use the platform dependent line separator.

Parameters:
out - a Writer object to provide the underlying stream.
Throws:
java.lang.IllegalArgumentException - if is .

LineWriter

public LineWriter(java.io.Writer out,
                  java.lang.String lineSeparator)
Construct a object that will use the specified line separator.

Parameters:
out - a Writer object to provide the underlying stream.
lineSeparator - String to use as line separator.
Throws:
java.lang.IllegalArgumentException - if or is .
Method Detail

getLineSeparator

public java.lang.String getLineSeparator()
Returns the current line separator.

Returns:
The current line separator.

setLineSeparator

public void setLineSeparator(java.lang.String lineSeparator)
Change the line separator. This is the string to insert in place of every occurences of "\r", "\n" or "\r\n".

Parameters:
lineSeparator - The new line separator.
Throws:
java.lang.IllegalArgumentException - if is .

write

public void write(int c)
           throws java.io.IOException
Write a single character.

Throws:
java.io.IOException - If an I/O error occurs

write

public void write(char[] cbuf,
                  int offset,
                  int length)
           throws java.io.IOException
Write a portion of an array of characters.

Parameters:
cbuf - Buffer of characters to be written
offset - Offset from which to start reading characters
length - Number of characters to be written
Throws:
java.io.IOException - If an I/O error occurs

write

public void write(java.lang.String string,
                  int offset,
                  int length)
           throws java.io.IOException
Write a portion of an array of a string.

Parameters:
string - String to be written
offset - Offset from which to start reading characters
length - Number of characters to be written
Throws:
java.io.IOException - If an I/O error occurs

flush

public void flush()
           throws java.io.IOException
Flush the stream's content to the underlying stream. This method flush completly all internal buffers, including any whitespace characters that should have been skipped if the next non-blank character is a line separator.

Throws:
java.io.IOException - If an I/O error occurs


Copyright © GeoTools. All Rights Reserved.