Top Description Fields Constructors Methods
java.io

public Class PrintWriter

extends Writer
Class Inheritance
Known Direct Subclasses
java.io.ProxyingConsole.WrappingWriter
Imports
java.util.Objects, .Formatter, .Locale, java.nio.charset.Charset, .IllegalCharsetNameException, .UnsupportedCharsetException

Prints formatted representations of objects to a text-output stream. This class implements all of the print methods found in PrintStream. It does not contain methods for writing raw bytes, for which a program should use unencoded byte streams.

Unlike the PrintStream class, if automatic flushing is enabled it will be done only when one of the println, printf, or format methods is invoked, rather than whenever a newline character happens to be output. These methods use the platform's own notion of line separator rather than the newline character.

Methods in this class never throw I/O exceptions, although some of its constructors may. The client may inquire as to whether any errors have occurred by invoking checkError().

This class always replaces malformed and unmappable character sequences with the charset's default replacement string. The java.nio.charset.CharsetEncoder class should be used when more control over the encoding process is required.

Authors
Frank Yellin, Mark Reinhold
Since
1.1

Field Summary

Modifier and TypeField and Description
private final boolean
private Formatter
protected Writer
out

The underlying character-output stream of this PrintWriter.

private PrintStream
private boolean
Inherited from java.io.Writer:
lock

Constructor Summary

AccessConstructor and Description
public
PrintWriter(Writer
A character-output stream
out
)

Creates a new PrintWriter, without automatic line flushing.

public
PrintWriter(Writer
A character-output stream
out
,
boolean
A boolean; if true, the println, printf, or format methods will flush the output buffer
autoFlush
)

Creates a new PrintWriter.

public
PrintWriter(OutputStream
An output stream
out
)

Creates a new PrintWriter, without automatic line flushing, from an existing OutputStream.

public
PrintWriter(OutputStream
An output stream
out
,
boolean
A boolean; if true, the println, printf, or format methods will flush the output buffer
autoFlush
)

Creates a new PrintWriter from an existing OutputStream.

public
PrintWriter(OutputStream
An output stream
out
,
boolean
A boolean; if true, the println, printf, or format methods will flush the output buffer
autoFlush
,
Charset charset)

Creates a new PrintWriter from an existing OutputStream.

public
PrintWriter(String
The name of the file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.
fileName
)

Creates a new PrintWriter, without automatic line flushing, with the specified file name.

pack-priv
private
PrintWriter(Charset charset, File file)

public
PrintWriter(String
The name of the file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.
fileName
,
String
The name of a supported charset
csn
)

Creates a new PrintWriter, without automatic line flushing, with the specified file name and charset.

public
PrintWriter(String
The name of the file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.
fileName
,
Charset charset)

Creates a new PrintWriter, without automatic line flushing, with the specified file name and charset.

public
PrintWriter(File
The file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.
file
)

Creates a new PrintWriter, without automatic line flushing, with the specified file.

public
PrintWriter(File
The file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.
file
,
String
The name of a supported charset
csn
)

Creates a new PrintWriter, without automatic line flushing, with the specified file and charset.

public
PrintWriter(File
The file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.
file
,
Charset charset)

Creates a new PrintWriter, without automatic line flushing, with the specified file and charset.

Method Summary

Modifier and TypeMethod and Description
public PrintWriter

Returns:

This writer
append
(CharSequence
The character sequence to append. If csq is null, then the four characters "null" are appended to this writer.
csq
)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends the specified character sequence to this writer.

public PrintWriter

Returns:

This writer
append
(CharSequence
The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".
csq
,
int
The index of the first character in the subsequence
start
,
int
The index of the character following the last character in the subsequence
end
)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends a subsequence of the specified character sequence to this writer.

public PrintWriter

Returns:

This writer
append
(char
The 16-bit character to append
c
)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends the specified character to this writer.

public boolean

Returns:

true if and only if this stream has encountered an IOException, or the setError method has been invoked
checkError
()

Flushes the stream if it's not closed and checks its error state.

protected void
clearError()

Clears the error state of this stream.

public void
close()

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Closes the stream and releases any system resources associated with it.

private void
ensureOpen()

Checks to make sure that the stream has not been closed

public void
flush()

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Flushes the stream.

public PrintWriter

Returns:

This writer
format
(String
A format string as described in Format string syntax.
format
,
Object...
Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.
args
)

Writes a formatted string to this writer using the specified format string and arguments.

public PrintWriter

Returns:

This writer
format
(Locale
The locale to apply during formatting. If l is null then no localization is applied.
l
,
String
A format string as described in Format string syntax.
format
,
Object...
Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.
args
)

Writes a formatted string to this writer using the specified format string and arguments.

private void
public PrintWriter

Returns:

This writer
printf
(String
A format string as described in Format string syntax.
format
,
Object...
Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.
args
)

A convenience method to write a formatted string to this writer using the specified format string and arguments.

public PrintWriter

Returns:

This writer
printf
(Locale
The locale to apply during formatting. If l is null then no localization is applied.
l
,
String
A format string as described in Format string syntax.
format
,
Object...
Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.
args
)

A convenience method to write a formatted string to this writer using the specified format string and arguments.

public void
println()

Terminates the current line by writing the line separator string.

public void
println(boolean
the boolean value to be printed
x
)

Prints a boolean value and then terminates the line.

public void
println(char
the char value to be printed
x
)

Prints a character and then terminates the line.

public void
println(int
the int value to be printed
x
)

Prints an integer and then terminates the line.

public void
println(long
the long value to be printed
x
)

Prints a long integer and then terminates the line.

public void
println(float
the float value to be printed
x
)

Prints a floating-point number and then terminates the line.

public void
println(double
the double value to be printed
x
)

Prints a double-precision floating-point number and then terminates the line.

public void
println(char[]
the array of char values to be printed
x
)

Prints an array of characters and then terminates the line.

public void
println(String
the String value to be printed
x
)

Prints a String and then terminates the line.

public void
println(Object
The Object to be printed.
x
)

Prints an Object and then terminates the line.

protected void
setError()

Sets the error state of the stream to true.

private static Charset
toCharset(String csn)

Returns a charset object for the given charset name.

public void
write(int
int specifying a character to be written.
c
)

Overrides java.io.Writer.write.

Writes a single character.

public void
write(char[]
Array of characters
buf
,
int
Offset from which to start writing characters
off
,
int
Number of characters to write
len
)

Implements abstract java.io.Writer.write.

Writes A Portion of an array of characters.

public void
write(char[]
Array of characters to be written
buf
)

Overrides java.io.Writer.write.

Writes an array of characters.

public void
write(String
A String
s
,
int
Offset from which to start writing characters
off
,
int
Number of characters to write
len
)

Overrides java.io.Writer.write.

Writes a portion of a string.

public void
write(String
String to be written
s
)

Overrides java.io.Writer.write.

Writes a string.

Inherited from java.io.Writer:
nullWriter

Field Detail

autoFlushback to summary
private final boolean autoFlush
formatterback to summary
private Formatter formatter
outback to summary
protected Writer out

The underlying character-output stream of this PrintWriter.

Since
1.2
psOutback to summary
private PrintStream psOut
troubleback to summary
private boolean trouble

Constructor Detail

PrintWriterback to summary
public PrintWriter(Writer out)

Creates a new PrintWriter, without automatic line flushing.

Parameters
out:Writer

A character-output stream

PrintWriterback to summary
public PrintWriter(Writer out, boolean autoFlush)

Creates a new PrintWriter.

Parameters
out:Writer

A character-output stream

autoFlush:boolean

A boolean; if true, the println, printf, or format methods will flush the output buffer

PrintWriterback to summary
public PrintWriter(OutputStream out)

Creates a new PrintWriter, without automatic line flushing, from an existing OutputStream. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will convert characters into bytes using the default charset, or where out is a PrintStream, the charset used by the print stream.

Parameters
out:OutputStream

An output stream

See Also
OutputStreamWriter#OutputStreamWriter(OutputStream), Charset#defaultCharset()
PrintWriterback to summary
public PrintWriter(OutputStream out, boolean autoFlush)

Creates a new PrintWriter from an existing OutputStream. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will convert characters into bytes using the default charset, or where out is a PrintStream, the charset used by the print stream.

Parameters
out:OutputStream

An output stream

autoFlush:boolean

A boolean; if true, the println, printf, or format methods will flush the output buffer

See Also
OutputStreamWriter#OutputStreamWriter(OutputStream), Charset#defaultCharset()
PrintWriterback to summary
public PrintWriter(OutputStream out, boolean autoFlush, Charset charset)

Creates a new PrintWriter from an existing OutputStream. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will convert characters into bytes using the specified charset.

Parameters
out:OutputStream

An output stream

autoFlush:boolean

A boolean; if true, the println, printf, or format methods will flush the output buffer

charset:Charset

A charset

Since
10
PrintWriterback to summary
public PrintWriter(String fileName) throws FileNotFoundException

Creates a new PrintWriter, without automatic line flushing, with the specified file name. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will encode characters using the default charset for this instance of the Java virtual machine.

Parameters
fileName:String

The name of the file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.

Exceptions
FileNotFoundException:
If the given string does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file
Since
1.5
See Also
Charset#defaultCharset()
PrintWriterback to summary
pack-priv PrintWriter(Writer out, Object lock)
PrintWriterback to summary
private PrintWriter(Charset charset, File file) throws FileNotFoundException
PrintWriterback to summary
public PrintWriter(String fileName, String csn) throws FileNotFoundException, UnsupportedEncodingException

Creates a new PrintWriter, without automatic line flushing, with the specified file name and charset. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will encode characters using the provided charset.

Parameters
fileName:String

The name of the file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.

csn:String

The name of a supported charset

Exceptions
FileNotFoundException:
If the given string does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file
UnsupportedEncodingException:
If the named charset is not supported
Since
1.5
PrintWriterback to summary
public PrintWriter(String fileName, Charset charset) throws IOException

Creates a new PrintWriter, without automatic line flushing, with the specified file name and charset. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will encode characters using the provided charset.

Parameters
fileName:String

The name of the file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.

charset:Charset

A charset

Exceptions
IOException:
if an I/O error occurs while opening or creating the file
Since
10
PrintWriterback to summary
public PrintWriter(File file) throws FileNotFoundException

Creates a new PrintWriter, without automatic line flushing, with the specified file. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will encode characters using the default charset for this instance of the Java virtual machine.

Parameters
file:File

The file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.

Exceptions
FileNotFoundException:
If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file
Since
1.5
See Also
Charset#defaultCharset()
PrintWriterback to summary
public PrintWriter(File file, String csn) throws FileNotFoundException, UnsupportedEncodingException

Creates a new PrintWriter, without automatic line flushing, with the specified file and charset. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will encode characters using the provided charset.

Parameters
file:File

The file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.

csn:String

The name of a supported charset

Exceptions
FileNotFoundException:
If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file
UnsupportedEncodingException:
If the named charset is not supported
Since
1.5
PrintWriterback to summary
public PrintWriter(File file, Charset charset) throws IOException

Creates a new PrintWriter, without automatic line flushing, with the specified file and charset. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will encode characters using the provided charset.

Parameters
file:File

The file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.

charset:Charset

A charset

Exceptions
IOException:
if an I/O error occurs while opening or creating the file
Since
10

Method Detail

appendback to summary
public PrintWriter append(CharSequence csq)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends the specified character sequence to this writer.

An invocation of this method of the form out.append(csq) when csq is not null, behaves in exactly the same way as the invocation

out.write(csq.toString())
out.write(csq.toString())

Depending on the specification of toString for the character sequence csq, the entire sequence may not be appended. For instance, invoking the toString method of a character buffer will return a subsequence whose content depends upon the buffer's position and limit.

Parameters
csq:CharSequence

The character sequence to append. If csq is null, then the four characters "null" are appended to this writer.

Returns:PrintWriter

This writer

Since
1.5
appendback to summary
public PrintWriter append(CharSequence csq, int start, int end)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends a subsequence of the specified character sequence to this writer.

An invocation of this method of the form out.append(csq, start, end) when csq is not null, behaves in exactly the same way as the invocation

out.write(csq.subSequence(start, end).toString())
out.write(csq.subSequence(start, end).toString())
Parameters
csq:CharSequence

The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".

start:int

The index of the first character in the subsequence

end:int

The index of the character following the last character in the subsequence

Returns:PrintWriter

This writer

Exceptions
IndexOutOfBoundsException:
If start or end are negative, start is greater than end, or end is greater than csq.length()
Since
1.5
appendback to summary
public PrintWriter append(char c)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends the specified character to this writer.

An invocation of this method of the form out.append(c) behaves in exactly the same way as the invocation

out.write(c)
out.write(c)
Parameters
c:char

The 16-bit character to append

Returns:PrintWriter

This writer

Since
1.5
checkErrorback to summary
public boolean checkError()

Flushes the stream if it's not closed and checks its error state.

Returns:boolean

true if and only if this stream has encountered an IOException, or the setError method has been invoked

clearErrorback to summary
protected void clearError()

Clears the error state of this stream.

This method will cause subsequent invocations of checkError() to return false until another write operation fails and invokes setError().

Since
1.6
closeback to summary
public void close()

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Closes the stream and releases any system resources associated with it. Closing a previously closed stream has no effect.

See Also
checkError()
ensureOpenback to summary
private void ensureOpen() throws IOException

Checks to make sure that the stream has not been closed

flushback to summary
public void flush()

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Flushes the stream.

See Also
checkError()
formatback to summary
public PrintWriter format(String format, Object... args)

Writes a formatted string to this writer using the specified format string and arguments. If automatic flushing is enabled, calls to this method will flush the output buffer.

The locale always used is the one returned by Locale.getDefault(), regardless of any previous invocations of other formatting methods on this object.

Parameters
format:String

A format string as described in Format string syntax.

args:Object[]

Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.

Returns:PrintWriter

This writer

Exceptions
IllegalFormatException:
If a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the Formatter class specification.
NullPointerException:
If the format is null
Since
1.5
formatback to summary
public PrintWriter format(Locale l, String format, Object... args)

Writes a formatted string to this writer using the specified format string and arguments. If automatic flushing is enabled, calls to this method will flush the output buffer.

Parameters
l:Locale

The locale to apply during formatting. If l is null then no localization is applied.

format:String

A format string as described in Format string syntax.

args:Object[]

Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.

Returns:PrintWriter

This writer

Exceptions
IllegalFormatException:
If a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the formatter class specification.
NullPointerException:
If the format is null
Since
1.5
newLineback to summary
private void newLine()
printfback to summary
public PrintWriter printf(String format, Object... args)

A convenience method to write a formatted string to this writer using the specified format string and arguments. If automatic flushing is enabled, calls to this method will flush the output buffer.

An invocation of this method of the form out.printf(format, args) behaves in exactly the same way as the invocation

out.format(format, args)
out.format(format, args)
Parameters
format:String

A format string as described in Format string syntax.

args:Object[]

Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.

Returns:PrintWriter

This writer

Exceptions
IllegalFormatException:
If a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the formatter class specification.
NullPointerException:
If the format is null
Since
1.5
printfback to summary
public PrintWriter printf(Locale l, String format, Object... args)

A convenience method to write a formatted string to this writer using the specified format string and arguments. If automatic flushing is enabled, calls to this method will flush the output buffer.

An invocation of this method of the form out.printf(l, format, args) behaves in exactly the same way as the invocation

out.format(l, format, args)
out.format(l, format, args)
Parameters
l:Locale

The locale to apply during formatting. If l is null then no localization is applied.

format:String

A format string as described in Format string syntax.

args:Object[]

Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.

Returns:PrintWriter

This writer

Exceptions
IllegalFormatException:
If a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the formatter class specification.
NullPointerException:
If the format is null
Since
1.5
printlnback to summary
public void println()

Terminates the current line by writing the line separator string. The line separator is System#lineSeparator() and is not necessarily a single newline character ('\n').

printlnback to summary
public void println(boolean x)

Prints a boolean value and then terminates the line. This method behaves as though it invokes print(boolean) and then println().

Parameters
x:boolean

the boolean value to be printed

printlnback to summary
public void println(char x)

Prints a character and then terminates the line. This method behaves as though it invokes print(char) and then println().

Parameters
x:char

the char value to be printed

printlnback to summary
public void println(int x)

Prints an integer and then terminates the line. This method behaves as though it invokes print(int) and then println().

Parameters
x:int

the int value to be printed

printlnback to summary
public void println(long x)

Prints a long integer and then terminates the line. This method behaves as though it invokes print(long) and then println().

Parameters
x:long

the long value to be printed

printlnback to summary
public void println(float x)

Prints a floating-point number and then terminates the line. This method behaves as though it invokes print(float) and then println().

Parameters
x:float

the float value to be printed

printlnback to summary
public void println(double x)

Prints a double-precision floating-point number and then terminates the line. This method behaves as though it invokes print(double) and then println().

Parameters
x:double

the double value to be printed

printlnback to summary
public void println(char[] x)

Prints an array of characters and then terminates the line. This method behaves as though it invokes print(char[]) and then println().

Parameters
x:char[]

the array of char values to be printed

printlnback to summary
public void println(String x)

Prints a String and then terminates the line. This method behaves as though it invokes print(String) and then println().

Parameters
x:String

the String value to be printed

printlnback to summary
public void println(Object x)

Prints an Object and then terminates the line. This method calls at first String.valueOf(x) to get the printed object's string value, then behaves as though it invokes print(String) and then println().

Parameters
x:Object

The Object to be printed.

setErrorback to summary
protected void setError()

Sets the error state of the stream to true.

This method will cause subsequent invocations of checkError() to return true until clearError() is invoked.

toCharsetback to summary
private static Charset toCharset(String csn) throws UnsupportedEncodingException

Returns a charset object for the given charset name.

Exceptions
UnsupportedEncodingException:
if the charset is not supported
NullPointerException:
is csn is null
writeback to summary
public void write(int c)

Overrides java.io.Writer.write.

Writes a single character.

Parameters
c:int

int specifying a character to be written.

writeback to summary
public void write(char[] buf, int off, int len)

Implements abstract java.io.Writer.write.

Writes A Portion of an array of characters.

Parameters
buf:char[]

Array of characters

off:int

Offset from which to start writing characters

len:int

Number of characters to write

Exceptions
IndexOutOfBoundsException:
If the values of the off and len parameters cause the corresponding method of the underlying Writer to throw an IndexOutOfBoundsException
writeback to summary
public void write(char[] buf)

Overrides java.io.Writer.write.

Writes an array of characters. This method cannot be inherited from the Writer class because it must suppress I/O exceptions.

Parameters
buf:char[]

Array of characters to be written

writeback to summary
public void write(String s, int off, int len)

Overrides java.io.Writer.write.

Writes a portion of a string.

Parameters
s:String

A String

off:int

Offset from which to start writing characters

len:int

Number of characters to write

Exceptions
IndexOutOfBoundsException:
If the values of the off and len parameters cause the corresponding method of the underlying Writer to throw an IndexOutOfBoundsException
writeback to summary
public void write(String s)

Overrides java.io.Writer.write.

Writes a string. This method cannot be inherited from the Writer class because it must suppress I/O exceptions.

Parameters
s:String

String to be written