public class XMLReader
extends java.io.Reader
Detecting of encoding is done first by reading a possible BOM, to detect
UTF-16 or UTF-8 then by reading a value from the XML header
<?xml version="1.0" encoding="..."?>
If encoding isn't specified, or it is not supported by the Java platform, the file is opened in UTF-8, in compliance with the XML specifications
Constructor and Description |
---|
XMLReader(java.io.File file)
Creates a new instance of XMLReader.
|
XMLReader(java.io.File file,
java.lang.String encoding)
Creates a new instance of XMLReader.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
java.lang.String |
getEncoding()
Returns detected encoding.
|
java.lang.String |
getEol()
Returns detected EOL chars.
|
int |
read(char[] cbuf,
int off,
int len) |
public XMLReader(java.io.File file) throws java.io.IOException
fileName
- - the file to readjava.io.IOException
public XMLReader(java.io.File file, java.lang.String encoding) throws java.io.IOException
encoding
, or (if supplied null, or
supplied encoding is not supported by JVM) falls back to UTF-8.fileName
- The file to read.encoding
- The encoding to use if we can't autodetect.java.io.IOException
public java.lang.String getEncoding()
public java.lang.String getEol()
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
public int read(char[] cbuf, int off, int len) throws java.io.IOException
read
in class java.io.Reader
java.io.IOException