java.lang.Object
java.io.Reader
net.morimekta.strings.io.Utf8StreamReader
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Readable
public class Utf8StreamReader
extends java.io.Reader
Similar to java native
InputStreamReader
, but locked to
utf-8, and explicitly with no buffering whatsoever. It will only read one
byte at a time until it has a valid unicode char.
In order to make this reader more efficient, rather wrap the input stream in a BufferedInputStream, which can pass on any buffered bytes to later uses. E.g.:
Reader reader = new Utf8StreamReader(new BufferedInputStream(in));
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Utf8StreamReader(java.io.InputStream in)
Utf8StreamReader(java.io.InputStream in, boolean strict)
-
Method Summary
-
Constructor Details
-
Utf8StreamReader
public Utf8StreamReader(java.io.InputStream in) -
Utf8StreamReader
public Utf8StreamReader(java.io.InputStream in, boolean strict)
-
-
Method Details
-
read
public int read(char[] char_buffer, int off, int len) throws java.io.IOException- Specified by:
read
in classjava.io.Reader
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Reader
- Throws:
java.io.IOException
-
ready
public boolean ready() throws java.io.IOException- Overrides:
ready
in classjava.io.Reader
- Throws:
java.io.IOException
-