|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.Writer
java.io.BufferedWriter
public class BufferedWriter
This class accumulates chars written in a buffer instead of immediately writing the data to the underlying output sink. The chars are instead as one large block when the buffer is filled, or when the stream is closed or explicitly flushed. This mode operation can provide a more efficient mechanism for writing versus doing numerous small unbuffered writes.
Field Summary |
---|
Fields inherited from class java.io.Writer |
---|
lock |
Constructor Summary | |
---|---|
BufferedWriter(Writer out)
This method initializes a new BufferedWriter instance
that will write to the specified subordinate Writer
and which will use a default buffer size of 8192 chars. |
|
BufferedWriter(Writer out,
int size)
This method initializes a new BufferedWriter instance
that will write to the specified subordinate Writer
and which will use the specified buffer size |
Method Summary | |
---|---|
void |
close()
This method flushes any remaining buffered chars then closes the underlying output stream. |
void |
flush()
This method causes any currently buffered chars to be immediately written to the underlying output stream. |
void |
newLine()
This method writes out a system depedent line separator sequence. |
void |
write(char[] buf,
int offset,
int len)
This method writes len chars from the char array
buf starting at position offset in the buffer. |
void |
write(int oneChar)
This method writes a single char of data. |
void |
write(String str,
int offset,
int len)
This method writes len chars from the String
str starting at position offset in the string. |
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 BufferedWriter(Writer out)
BufferedWriter
instance
that will write to the specified subordinate Writer
and which will use a default buffer size of 8192 chars.
out
- The underlying Writer
to write data topublic BufferedWriter(Writer out, int size)
BufferedWriter
instance
that will write to the specified subordinate Writer
and which will use the specified buffer size
out
- The underlying Writer
to write data tosize
- The size of the internal bufferMethod Detail |
---|
public void close() throws IOException
close
in interface Closeable
close
in class Writer
IOException
- If an error occurs.public void flush() throws IOException
flush
in interface Flushable
flush
in class Writer
IOException
- If an error occurspublic void newLine() throws IOException
IOException
- If an error occurspublic void write(int oneChar) throws IOException
write
in class Writer
oneChar
- The char of data to be written, passed as an int
IOException
- If an error occurspublic void write(char[] buf, int offset, int len) throws IOException
len
chars from the char array
buf
starting at position offset
in the buffer.
These chars will be written to the internal buffer. However, if this
write operation fills the buffer, the buffer will be flushed to the
underlying output stream.
write
in class Writer
buf
- The array of chars to write.offset
- The index into the char array to start writing from.len
- The number of chars to write.
IOException
- If an error occurspublic void write(String str, int offset, int len) throws IOException
len
chars from the String
str
starting at position offset
in the string.
These chars will be written to the internal buffer. However, if this
write operation fills the buffer, the buffer will be flushed to the
underlying output stream.
write
in class Writer
str
- The String
to write.offset
- The index into the string to start writing from.len
- The number of chars to write.
IOException
- If an error occurs
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |