Package org.ka2ddo.util
Class UTF8StreamReader
java.lang.Object
java.io.Reader
org.ka2ddo.util.UTF8StreamReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
This class implements an optimized stream-to-reader conversion assuming only UTF-8.
- Author:
- Andrew Pavlin, KA2DDO
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate a UTF8StreamReader wrapped around the specified InputStream. -
Method Summary
Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, ready, reset, skip, transferTo
-
Constructor Details
-
UTF8StreamReader
Create a UTF8StreamReader wrapped around the specified InputStream.- Parameters:
in
- InputStream to read and decode
-
-
Method Details
-
read
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.- Overrides:
read
in classReader
- Returns:
- The character read, as an integer in the range 0 to 65535
(
0x00-0xffff
), or -1 if the end of the stream has been reached - Throws:
IOException
- If an I/O error occurs
-
read
Reads characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.- Specified by:
read
in classReader
- Parameters:
cbuf
- Destination bufferoff
- Offset at which to start storing characterslen
- Maximum number of characters to read- Returns:
- The number of characters read, or -1 if the end of the stream has been reached
- Throws:
IOException
- If an I/O error occurs
-
close
Closes the stream and releases any system resources associated with it. Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
- If an I/O error occurs
-