public final class XmlReader extends Reader
Note that the autodetection facility should be used only on data streams which have an unknown character encoding. For example, it should never be used on MIME text/xml entities.
Note that XML processors are only required to support UTF-8 and UTF-16 character encodings. Autodetection permits the underlying Java implementation to provide support for many other encodings, such as US-ASCII, ISO-8859-5, Shift_JIS, EUC-JP, and ISO-2022-JP.
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the reader.
|
static XmlReader |
createReader(InputStream in)
Constructs the reader from an input stream, autodetecting
the encoding to use according to the heuristic specified
in the XML 1.0 recommendation.
|
static Reader |
createReader(InputStream in,
String encoding)
Creates a reader supporting the given encoding, mapping
from standard encoding names to ones that understood by
Java where necessary.
|
String |
getEncoding()
Returns the standard name of the encoding in use
|
InputStream |
getInputStream() |
void |
mark(int value)
Sets a mark allowing a limited number of characters to
be "peeked", by reading and then resetting.
|
boolean |
markSupported()
Returns true iff the reader supports mark/reset.
|
int |
read()
Reads a single character.
|
int |
read(char[] buf,
int off,
int len)
Reads the number of characters read into the buffer, or -1 on EOF.
|
boolean |
ready()
Returns true iff input characters are known to be ready.
|
void |
reset()
Resets the current position to the last marked position.
|
long |
skip(long value)
Skips a specified number of characters.
|
public static XmlReader createReader(InputStream in) throws IOException
in
- the input stream from which the reader is constructedIOException
- on error, such as unrecognized encodingpublic static Reader createReader(InputStream in, String encoding) throws IOException
in
- the input stream from which the reader is constructedencoding
- the IETF standard name of the encoding to use;
if null, autodetection is used.IOException
- on error, including unrecognized encodingpublic String getEncoding()
public InputStream getInputStream()
public int read(char[] buf, int off, int len) throws IOException
read
in class Reader
IOException
public int read() throws IOException
read
in class Reader
IOException
public boolean markSupported()
markSupported
in class Reader
public void mark(int value) throws IOException
mark
in class Reader
value
- how many characters may be "peeked".IOException
public void reset() throws IOException
reset
in class Reader
IOException
public long skip(long value) throws IOException
skip
in class Reader
IOException
public boolean ready() throws IOException
ready
in class Reader
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class Reader
IOException
Copyright © 2002-2017 Atlassian. All Rights Reserved.