Build 1.0_r1(from source)

java.io
Class BufferedWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.BufferedWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

public class BufferedWriter
extends Writer

BufferedWriter is for writing buffered character output. Characters written to this Writer are buffered internally before being committed to the target Writer.

See Also:
BufferedReader

Field Summary
 
Fields inherited from class java.io.Writer
lock, TOKEN_NULL
 
Constructor Summary
BufferedWriter(Writer out)
          Constructs a new BufferedReader with out as the Writer on which to buffer write operations.
BufferedWriter(Writer out, int size)
          Constructs a new BufferedReader with out as the Writer on which buffer write operations.
 
Method Summary
 void close()
          Close this BufferedWriter.
 void flush()
          Flush this BufferedWriter.
 void newLine()
          Write a newline to thie Writer.
 void write(char[] cbuf, int offset, int count)
          Writes out count characters starting at offset in buf to this BufferedWriter.
 void write(int oneChar)
          Writes the character oneChar BufferedWriter.
 void write(String str, int offset, int count)
          Writes out count characters starting at offset in str to this BufferedWriter.
 
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

BufferedWriter

public BufferedWriter(Writer out)
Constructs a new BufferedReader with out as the Writer on which to buffer write operations. The buffer size is set to the default, which is 8K.

Parameters:
out - The Writer to buffer character writing on

BufferedWriter

public BufferedWriter(Writer out,
                      int size)
Constructs a new BufferedReader with out as the Writer on which buffer write operations. The buffer size is set to size.

Parameters:
out - The Writer to buffer character writing on.
size - The size of the buffer to use.
Method Detail

close

public void close()
           throws IOException
Close this BufferedWriter. The contents of the buffer are flushed, the target writer is closed, and the buffer is released. Only the first invocation of close has any effect.

Specified by:
close in interface Closeable
Specified by:
close in class Writer
Throws:
IOException - If an error occurs attempting to close this Writer.

flush

public void flush()
           throws IOException
Flush this BufferedWriter. The contents of the buffer are committed to the target writer and it is then flushed.

Specified by:
flush in interface Flushable
Specified by:
flush in class Writer
Throws:
IOException - If an error occurs attempting to flush this Writer.

newLine

public void newLine()
             throws IOException
Write a newline to thie Writer. A newline is determined by the System property "line.separator". The target writer may or may not be flushed when a newline is written.

Throws:
IOException - If an error occurs attempting to write to this Writer.

write

public void write(char[] cbuf,
                  int offset,
                  int count)
           throws IOException
Writes out count characters starting at offset in buf to this BufferedWriter. If count is greater than this Writers buffer then flush the contents and also write the characters directly to the target Writer.

Specified by:
write in class Writer
Parameters:
cbuf - the non-null array containing characters to write.
offset - offset in buf to retrieve characters
count - maximum number of characters to write
Throws:
IOException - If this Writer has already been closed or some other IOException occurs.
IndexOutOfBoundsException - If offset or count are outside of bounds.

write

public void write(int oneChar)
           throws IOException
Writes the character oneChar BufferedWriter. If the buffer is filled by writing this character, flush this Writer. Only the lower 2 bytes are written.

Overrides:
write in class Writer
Parameters:
oneChar - The Character to write out.
Throws:
IOException - If this Writer has already been closed or some other IOException occurs.

write

public void write(String str,
                  int offset,
                  int count)
           throws IOException
Writes out count characters starting at offset in str to this BufferedWriter. If count is greater than this Writers buffer then flush the contents and also write the characters directly to the target Writer.

Overrides:
write in class Writer
Parameters:
str - the non-null String containing characters to write
offset - offset in str to retrieve characters
count - maximum number of characters to write
Throws:
IOException - If this Writer has already been closed or some other IOException occurs.
ArrayIndexOutOfBoundsException - If offset or count are outside of bounds.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature