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 PrintWriter
ImplementsAppendable, AutoCloseable, Closeable, Flushable
Prints formatted text to a writer or a stream. It never throws: an I/O error is recorded and reported by
checkError.Fields
protected Writer out |
Constructors
public PrintWriter(Writer out) | |
public PrintWriter(Writer out, boolean autoFlush) | |
public PrintWriter(OutputStream out) | |
public PrintWriter(OutputStream out, boolean autoFlush) |
Methods
Inherited fields
Inherited methods
Field details
out
protected Writer outConstructor details
PrintWriter
public PrintWriter(Writer out)PrintWriter
public PrintWriter(Writer out, boolean autoFlush)PrintWriter
public PrintWriter(OutputStream out)PrintWriter
public PrintWriter(OutputStream out, boolean autoFlush)Method details
checkError
public boolean checkError()setError
protected void setError()clearError
protected void clearError()flush
public void flush()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()Closes the delegate and drops it, as the JDK does: a later write or
flush is then suppressed and recorded as an error for
checkError,
even when the delegate’s own close is a no-op (a StringWriter). A
second close does nothing.write
public void write(int c)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[] buf, int off, int len)Write a portion of an array of characters.
write
public void write(char[] buf)Write an array of characters.
write
public void write(String s, int off, int len)Write a portion of a string.
write
public void write(String s)Write a string.
public void print(String s)public void print(Object o)public void print(char c)public void print(char[] s)public void print(boolean b)public void print(int i)public void print(long l)public void print(float f)public void print(double d)println
public void println()println
public void println(String s)println
public void println(Object o)println
public void println(char c)println
public void println(char[] s)println
public void println(boolean b)println
public void println(int i)println
public void println(long l)println
public void println(float f)println
public void println(double d)append
public PrintWriter append(CharSequence csq)Writes
csq, or “null” when it is null.Parameters
csqCharSequence- the character sequence to append.
Returns
this
Appendable.Throws
IOException- if an I/O error occurs.
append
public PrintWriter append(char c)Writes
c.Parameters
cchar- the character to append.
Returns
this
Appendable.Throws
IOException- if an I/O error occurs.
printf
public PrintWriter printf(String format, Object... args)Writes
format filled in with args, as String.format does.Returns
this writer
format
public PrintWriter format(String format, Object... args)Writes
format filled in with args, as String.format does.Returns
this writer
append
public PrintWriter append(CharSequence csq, int start, int end)Writes the characters of
csq from start up to end.Parameters
csqCharSequence- the character sequence to append.
startint- the first index of the subsequence of
csqthat is appended. endint- the last index of the subsequence of
csqthat is appended.
Returns
this
Appendable.Throws
IndexOutOfBoundsException- if
start endorendis greater than the length ofcsq. IOException- if an I/O error occurs.