KIOSourceBufferedReader
Multiplatform buffered character reader that mirrors the API of Java's BufferedReader:contentReferenceoaicite:0{index=0}. It reads text from a Source (byte stream) and buffers characters to provide efficient reading of single characters, arrays, and lines:contentReferenceoaicite:1{index=1}. The buffer size may be specified, or a default size (8192) is used, which is large enough for most purposes:contentReferenceoaicite:2{index=2}.
This class uses a kotlinx.io.Source as the underlying input and decodes bytes to characters using UTF-8. It supports marking a position in the input and resetting back to that position, and is intended to behave like java.io.BufferedReader.
Functions
Closes the stream and the underlying source, releasing any resources:contentReferenceoaicite:28{index=28}. Once the stream is closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException:contentReferenceoaicite:29{index=29}. Closing a previously closed stream has no effect:contentReferenceoaicite:30{index=30}.
Marks the present position in the stream:contentReferenceoaicite:15{index=15}. Subsequent calls to reset will attempt to reposition the stream to this point:contentReferenceoaicite:16{index=16}. The readAheadLimit argument tells how many characters may be read while still preserving the mark. If more than readAheadLimit chars are read after marking, the mark is invalidated.
Indicates whether this stream supports the mark operation, which it does:contentReferenceoaicite:23{index=23}.
Reads a single character from the stream:contentReferenceoaicite:5{index=5}. Returns the character as an integer (0-65535) or -1 if the end of the stream has been reached:contentReferenceoaicite:6{index=6}.
Reads up to len characters into the specified portion of the character array cbuf:contentReferenceoaicite:7{index=7}. It returns the number of characters read, or -1 if the end of the stream has been reached before any characters are read:contentReferenceoaicite:8{index=8}. This method will block until at least one character is available or end-of-stream is detected.
Reads characters into a CharBuffer. This default implementation reads into an array and then puts the characters into the buffer.
Reads a line of text from the stream:contentReferenceoaicite:9{index=9}. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a line feed:contentReferenceoaicite:10{index=10}. The line-termination characters are not included in the returned string.
Resets the stream to the most recent mark:contentReferenceoaicite:20{index=20}. After reset, the stream will read input from the point where mark was last called. If the stream has not been marked or if the mark was invalidated due to reading beyond the read-ahead limit, an IOException is thrown:contentReferenceoaicite:21{index=21}.
Skips over n characters in the stream:contentReferenceoaicite:25{index=25}. This method may read and discard characters in multiple chunks until the specified number of characters have been skipped or the end of stream is reached. It returns the actual number of characters skipped.
Reads all characters from this Reader and writes them to out. Returns the number of characters transferred.