# writeString method

Future<void> writeString(

1. String str

)

Writes a string to this output stream using UTF-8 encoding.

This is a convenience method for writing text data. The string is encoded as UTF-8 bytes and written to the stream.

## Parameters

- `str`: The string to write

## Example

    final output = FileOutputStream('text_output.txt');
    try {
      await output.writeString('Hello, World!');
      await output.writeString('\n');
      await output.writeString('This is a test.');
      await output.flush();
    } finally {
      await output.close();
    }

Throws IOException if an I/O error occurs. Throws StreamClosedException if the stream has been closed.

## Implementation

    Future<void> writeString(String str) async {
      final bytes = Uint8List.fromList(str.codeUnits);
      await writeBytes(bytes);
    }