final class XmlInputStream extends InputStream
Modifier and Type | Field and Description |
---|---|
private byte[] |
buffer
The buffer read to lookahead the encoding from the XML header.
|
private Charset |
charset
The encoding detected from the XML header or
null if it was NOT specified. |
private InputStream |
delegate
The original input-stream to adapt.
|
private int |
index
The current index position in the
buffer . |
private int |
length
the length of the buffered data (may be less than the array length).
|
private static byte[] |
XML_ENCODING_ATRIBUTE
the start of the XML encoding attribute (
"encoding=" ). |
private static byte[] |
XML_HEADER_START
the start of the XML header (
"<?xml" ). |
Constructor and Description |
---|
XmlInputStream(InputStream delegate,
Charset defaultCharset)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
Charset |
getCharset()
This method gets the
Charset that was detected. |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
available, mark, markSupported, read, reset, skip
private static final byte[] XML_HEADER_START
"<?xml"
).private static final byte[] XML_ENCODING_ATRIBUTE
"encoding="
).private final InputStream delegate
private final byte[] buffer
private final int length
private int index
buffer
.private Charset charset
null
if it was NOT specified.public XmlInputStream(InputStream delegate, Charset defaultCharset) throws IOException
delegate
- is the input-stream to adapt.defaultCharset
- is the Charset
used if NO encoding was specified via an XML header.IOException
- if an I/O error was caused by delegate
when trying to read the XML header.public Charset getCharset()
Charset
that was detected.public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
Copyright © 2001–2016 mmm-Team. All rights reserved.