Package org.omegat.filters3.xml
Class XMLReader
java.lang.Object
java.io.Reader
org.omegat.filters3.xml.XMLReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
This class automatically detects encoding of an inner XML file and constructs
a Reader with appropriate encoding.
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 Summary
Constructors -
Method Summary
Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, read, ready, reset, skip, transferTo
-
Constructor Details
-
XMLReader
Creates a new instance of XMLReader. If encoding cannot be detected, falls back to default UTF-8.- Parameters:
is- the InputStream instance to read- Throws:
IOException
-
XMLReader
Creates a new instance of XMLReader. If encoding cannot be detected, falls back to default UTF-8.- Parameters:
file- - the file to read- Throws:
IOException
-
XMLReader
Creates a new instance of XMLReader. If encoding cannot be detected, falls back to suppliedencoding, or (if supplied null, or supplied encoding is not supported by JVM) falls back to UTF-8.- Parameters:
file- The file to read.defaultEncoding- The encoding to use if we can't autodetect.- Throws:
IOException
-
-
Method Details
-
getEncoding
Returns detected encoding. -
getEol
Returns detected EOL chars. -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException
-
read
- Specified by:
readin classReader- Throws:
IOException
-