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.

FileWriter, PrintWriter, StringWriter

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.
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.

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

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(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.

close(): void

Closes the writer.


flush(): void

Flushes the buffer.


write(str: String): void

Write the given string to the stream.

Parameters:

  • str - the string to write to the stream.

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.