Writer class methods in Java

java.io.Writer

Abstract class for writing to character streams. The only methods that a subclass must implement are write(char[], int, int), flush(), and close().Most subclasses, however, will override some of the methods defined here in order to provide higher efficiency, additional functionality, or both.

Implemented Interfaces:

Closeable

Flushable

Appendable

AutoCloseable

Subclasses:

BufferedWriter

CharArrayWriter

FilterWriter

OutputStreamWriter

PipedWriter

PrintWriter

StringWriter

Some methods of Writer class

append(char): This method appends the specified character to this writer.

append(CharSequence): This method appends the specified character sequence to this writer.

append(CharSequence, int, int): This method appends a subsequence of the specified character sequence to this writer.Appendable.

close(): This method closes the stream, flushing it first.

flush(): This method flushes the stream.

Writer.nullWriter(): This method returns a new Writer who discards all characters

write(char[]): This method writes an array of characters.

write(int): This method writes a single character.

write(String): This method writes a string.

write(char[], int, int): This method writes a portion of an array of characters.

write(String, int, int): This method writes a portion of a string.

No comments:

Post a Comment