Class Writer

The class supports writing characters to a stream.

Note: when this class is used with sensitive data, be careful in persisting sensitive information to disk.

All Known Subclasses 

FileWriter, PrintWriter, StringWriter

Constructor Summary 

ConstructorDescription
Writer(OutputStream)Create a writer from a stream using UTF-8 character encoding.
Writer(OutputStream, String)Create a writer from a stream using the specified character encoding.

Method Summary 

MethodDescription
close()Closes the writer.
flush()Flushes the buffer.
write(String)Write the given string to the stream.
write(String, Number, Number)Write the given string to the stream.

Methods inherited from class Object 

assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values

Constructor Details 

Writer(OutputStream) 

Writer(stream: OutputStream)

Create a writer from a stream using UTF-8 character encoding.

Parameters:

  • stream - the output stream to use when creating the writer.

Writer(OutputStream, String) 

Writer(stream: OutputStream, encoding: String)

Create a writer from a stream using the specified character encoding.

Parameters:

  • stream - the output stream to use when creating the writer.
  • encoding - the encoding to use when creating the writer.

Method Details 

close() 

close(): void

Closes the writer.


flush() 

flush(): void

Flushes the buffer.


write(String) 

write(str: String): void

Write the given string to the stream.

Parameters:

  • str - the string to write to the stream.

write(String, Number, Number) 

write(str: String, off: Number, len: Number): void

Write the given string to the stream.

Parameters:

  • str - the string to write to the stream.
  • off - the offset from which to start writing characters to the stream.
  • len - the number of characters to write from the stream.