# writeByte method

1. @override

Future<void> writeByte(

1. int b

)
override

Writes the specified byte to this output stream.

The general contract for writeByte is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument `b`. The 24 high-order bits of `b` are ignored.

## Parameters

- `b`: The byte to write (only the low-order 8 bits are used)

## Example

    final output = FileOutputStream('output.txt');
    try {
      await output.writeByte(65); // Write 'A'
      await output.writeByte(66); // Write 'B'
      await output.writeByte(67); // Write 'C'
      await output.flush();
    } finally {
      await output.close();
    }

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

## Implementation

    @override
    Future<void> writeByte(int b) async {
      await _ensureOpen();

      try {
        await _randomAccessFile!.writeByte(b & 0xFF);
        _position++;
      } catch (e) {
        throw IOException('Error writing to file: ${_file.path}', cause: e);
      }
    }