|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.Reader
org.fife.io.UnicodeReader
public class UnicodeReader
A reader capable of identifying Unicode streams by their BOMs. This class will recognize the following encodings:
For optimum performance, it is recommended that you wrap all instances of
UnicodeReader with a java.io.BufferedReader.
This class is mostly ripped off from the workaround in the description of Java Bug 4508058.
| Field Summary |
|---|
| Fields inherited from class java.io.Reader |
|---|
lock |
| Constructor Summary | |
|---|---|
UnicodeReader(File file)
This utility constructor is here because you will usually use a UnicodeReader on files. |
|
UnicodeReader(File file,
String defaultEncoding)
This utility constructor is here because you will usually use a UnicodeReader on files. |
|
UnicodeReader(InputStream in)
Creates a reader using the encoding specified by the BOM in the file; if there is no recognized BOM, then a system default encoding is used. |
|
UnicodeReader(InputStream in,
String defaultEncoding)
Creates a reader using the encoding specified by the BOM in the file; if there is no recognized BOM, then defaultEncoding is
used. |
|
UnicodeReader(String file)
This utility constructor is here because you will usually use a UnicodeReader on files. |
|
| Method Summary | |
|---|---|
void |
close()
Closes this reader. |
String |
getEncoding()
Returns the encoding being used to read this input stream (i.e., the encoding of the file). |
protected void |
init(InputStream in,
String defaultEncoding)
Read-ahead four bytes and check for BOM marks. |
int |
read(char[] cbuf,
int off,
int len)
Read characters into a portion of an array. |
| Methods inherited from class java.io.Reader |
|---|
mark, markSupported, read, read, read, ready, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public UnicodeReader(String file)
throws IOException,
FileNotFoundException,
SecurityException
UnicodeReader on files.Creates a reader using the encoding specified by the BOM in the file; if there is no recognized BOM, then a system default encoding is used.
file - The file from which you want to read.
IOException - If an error occurs when checking for/reading the
BOM.
FileNotFoundException - If the file does not exist, is a
directory, or cannot be opened for reading.
SecurityException - If a security manager exists and its
checkRead method denies read access to the file.
public UnicodeReader(File file)
throws IOException,
FileNotFoundException,
SecurityException
UnicodeReader on files.Creates a reader using the encoding specified by the BOM in the file; if there is no recognized BOM, then a system default encoding is used.
file - The file from which you want to read.
IOException - If an error occurs when checking for/reading the
BOM.
FileNotFoundException - If the file does not exist, is a
directory, or cannot be opened for reading.
SecurityException - If a security manager exists and its
checkRead method denies read access to the file.
public UnicodeReader(File file,
String defaultEncoding)
throws IOException,
FileNotFoundException,
SecurityException
UnicodeReader on files.Creates a reader using the encoding specified by the BOM in the file; if there is no recognized BOM, then a specified default encoding is used.
file - The file from which you want to read.defaultEncoding - The encoding to use if no BOM is found. If
this value is null, a system default is used.
IOException - If an error occurs when checking for/reading the
BOM.
FileNotFoundException - If the file does not exist, is a
directory, or cannot be opened for reading.
SecurityException - If a security manager exists and its
checkRead method denies read access to the file.
public UnicodeReader(InputStream in)
throws IOException
in - The input stream from which to read.
IOException - If an error occurs when checking for/reading the
BOM.
public UnicodeReader(InputStream in,
String defaultEncoding)
throws IOException
defaultEncoding is
used.
in - The input stream from which to read.defaultEncoding - The encoding to use if no recognized BOM is
found. If this value is null, a system default
is used.
IOException - If an error occurs when checking for/reading the
BOM.| Method Detail |
|---|
public void close()
throws IOException
close in interface Closeableclose in class ReaderIOExceptionpublic String getEncoding()
protected void init(InputStream in,
String defaultEncoding)
throws IOException
defaultEncoding - The encoding to use if no BOM was recognized. If
this value is null, then a system default is used.
IOException - If an error occurs when trying to read a BOM.
public int read(char[] cbuf,
int off,
int len)
throws IOException
read in class Readercbuf - The buffer into which to read.off - The offset at which to start storing characters.len - The maximum number of characters to read.
-1 if the end
of the stream has been reached.
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||