readChar abstract method

Future<int> readChar()

Reads a single character.

This method will block until a character is available, an I/O error occurs, or the end of the stream is reached.

Returns

The character read, as an integer in the range 0 to 65535, or -1 if the end of the stream has been reached.

Example

final reader = FileReader('text.txt');
try {
  int char;
  while ((char = await reader.readChar()) != -1) {
    print('Character: ${String.fromCharCode(char)}');
  }
} finally {
  await reader.close();
}

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

Implementation

Future<int> readChar();