Class XmlStreamReader
java.lang.Object
java.io.Reader
net.adoptopenjdk.icedteaweb.xmlparser.XmlStreamReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
This Reader will examine the wrapped input stream according to
appendix F of the XML specification in order to guess the encoding
of the XML content in the stream.
If the encoding cannot be guessed the reader falls back to the
XML - Appendix F
defaultEncoding.
The following aspects of the input stream are examined in the order below
- Byte order mark (BOM)
- First 20 byes to see if content starts with "<?xml"
- XML encoding declaration
- Default encoding
XML - Appendix F
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor UTF-8 default encoding.XmlStreamReader(InputStream in, Charset defaultEncoding) Constructor with passed in default encoding. -
Method Summary
Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, reset, skip, transferTo
-
Constructor Details
-
XmlStreamReader
Constructor UTF-8 default encoding. This constructor is equivalent to calling:
new XmlStreamReader(in, StandardCharsets.UTF_8)- Parameters:
in- an input stream with XML content.- Throws:
IOException
-
XmlStreamReader
Constructor with passed in default encoding.- Parameters:
in- an input stream with XML content.defaultEncoding- the encoding to use if no encoding can be derived from the content of the stream- Throws:
IOException
-
-
Method Details
-
getEncoding
Returns the name of the character encoding being used by this stream.If the encoding has an historical name then that name is returned; otherwise the encoding's canonical name is returned.
If this instance was created with the
XmlStreamReader(InputStream, Charset)constructor then the returned name, being unique for the encoding, may differ from the name passed to the constructor. This method will returnnullif the stream has been closed.- Returns:
- The historical name of this encoding, or
nullif the stream has been closed - See Also:
-
ready
- Overrides:
readyin classReader- Throws:
IOException
-
read
- Overrides:
readin classReader- Throws:
IOException
-
read
- Specified by:
readin classReader- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException
-