public class CharsetMatch extends Object implements Comparable<CharsetMatch>
Instances of this class are created only by CharsetDetectors.
Note: this class has a natural ordering that is inconsistent with equals. The natural ordering is based on the match confidence value.
Modifier and Type | Method and Description |
---|---|
int |
compareTo(CharsetMatch other)
Compare to other CharsetMatch objects.
|
int |
getConfidence()
Get an indication of the confidence in the charset detected.
|
String |
getLanguage()
Get the ISO code for the language of the detected charset.
|
String |
getName()
Get the name of the detected charset.
|
Reader |
getReader()
Create a java.io.Reader for reading the Unicode character data corresponding
to the original byte data supplied to the Charset detect operation.
|
String |
getString()
Create a Java String from Unicode character data corresponding
to the original byte data supplied to the Charset detect operation.
|
String |
getString(int maxLength)
Create a Java String from Unicode character data corresponding
to the original byte data supplied to the Charset detect operation.
|
public Reader getReader()
CAUTION: if the source of the byte data was an InputStream, a Reader can be created for only one matching char set using this method. If more than one charset needs to be tried, the caller will need to reset the InputStream and create InputStreamReaders itself, based on the charset name.
public String getString() throws IOException
IOException
public String getString(int maxLength) throws IOException
maxLength
- The maximum length of the String to be created when the
source of the data is an input stream, or -1 for
unlimited length.IOException
public int getConfidence()
public String getName()
Charset
,
InputStreamReader
public String getLanguage()
null
if the language cannot be determined.public int compareTo(CharsetMatch other)
compareTo
in interface Comparable<CharsetMatch>
other
- the CharsetMatch object to compare against.ClassCastException
- if the argument is not a CharsetMatch.Copyright © 2016 Unicode, Inc. and others.