Package net.morimekta.util.io
Class Utf8StreamReader
- java.lang.Object
-
- java.io.Reader
-
- net.morimekta.util.io.Utf8StreamReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Readable
public class Utf8StreamReader extends java.io.Reader
Similar to java nativeInputStreamReader
, 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));
-
-
Constructor Summary
Constructors Constructor Description Utf8StreamReader(java.io.InputStream in)
Utf8StreamReader(java.io.InputStream in, boolean strict)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
int
read(char[] char_buffer, int off, int len)
boolean
ready()
-
-
-
Method Detail
-
read
public int read(@Nonnull 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
-
-