Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public class BufferedWriter

  1. Object
  2. Writer
  3. BufferedWriter

ImplementsAppendable, AutoCloseable, Closeable, Flushable

Writes text to another writer through a buffer.

Constructors

public BufferedWriter(Writer out)Buffers out with an 8192 character buffer.
public BufferedWriter(Writer out, int size)Buffers out with a buffer of size characters.

Methods

public void write(int c) throws IOExceptionWrite a single character.
public void write(char[] cbuf, int off, int len) throws IOExceptionWrite a portion of an array of characters.
public void write(String s, int off, int len) throws IOExceptionWrite a portion of a string.
public void newLine() throws IOExceptionWrites a line separator, \n.
public void flush() throws IOExceptionFlush the stream.
public void close() throws IOExceptionClose the stream, flushing it first.

Inherited fields

Inherited methods

Constructor details

BufferedWriter

public BufferedWriter(Writer out)
Buffers out with an 8192 character buffer.

BufferedWriter

public BufferedWriter(Writer out, int size)
Buffers out with a buffer of size characters.

Throws

IllegalArgumentException
when size is not positive

Method details

write

public void write(int c) throws IOException
Write a single character. The character to be written is contained in the 16 low-order bits of the given integer value; the 16 high-order bits are ignored. Subclasses that intend to support efficient single-character output should override this method.

write

public void write(char[] cbuf, int off, int len) throws IOException
Write a portion of an array of characters.

write

public void write(String s, int off, int len) throws IOException
Write a portion of a string.

newLine

public void newLine() throws IOException
Writes a line separator, \n.

flush

public void flush() throws IOException
Flush the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.

Throws

IOException
if there are any issues writing the data.

close

public void close() throws IOException
Close the stream, flushing it first. Once a stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously-closed stream, however, has no effect.