public class CharsetDetectingReader
extends java.io.Reader
Reader
that wraps an InputStream
and automatically takes
care of guessing the input stream's encoding, using the jchardet library.
Guessing is done on the fly without rewinding.Modifier and Type | Field and Description |
---|---|
private byte[] |
buffer |
private static int |
DEFAULT_BUFFER_SIZE |
private java.lang.String |
detectedEncoding |
private org.mozilla.intl.chardet.nsDetector |
detector |
private boolean |
encodingDetected |
private static int |
EOF |
private java.lang.String |
guessedEncoding |
private java.io.InputStream |
in |
private static org.slf4j.Logger |
log |
private java.io.Reader |
reader |
Constructor and Description |
---|
CharsetDetectingReader(java.io.InputStream in)
Class constructor.
|
CharsetDetectingReader(java.io.InputStream in,
int bufferSize)
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
private boolean |
fillBuffer() |
int |
read(char[] cbuf,
int off,
int len) |
private static final org.slf4j.Logger log
private static final int DEFAULT_BUFFER_SIZE
private static final int EOF
private final java.io.InputStream in
private final byte[] buffer
private final org.mozilla.intl.chardet.nsDetector detector
private java.io.Reader reader
private boolean encodingDetected
private java.lang.String detectedEncoding
private java.lang.String guessedEncoding
public CharsetDetectingReader(java.io.InputStream in)
in
- Input stream.public CharsetDetectingReader(java.io.InputStream in, int bufferSize)
in
- Input stream.bufferSize
- Buffer size.public int read(char[] cbuf, int off, int len) throws java.io.IOException
read
in class java.io.Reader
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.Reader
java.io.IOException
private boolean fillBuffer() throws java.io.IOException
java.io.IOException