public class UnicodeInputStream extends InputStream
getEncodingFromStream() on
the input stream reader.
This class is not thread safe! When more than one thread wants to use an instance of UnicodeInputStream,
the caller must provide synchronization.| Modifier and Type | Field and Description |
|---|---|
static org.apache.velocity.io.UnicodeInputStream.UnicodeBOM |
UTF16BE_BOM
BOM Marker for UTF 16, big endian.
|
static org.apache.velocity.io.UnicodeInputStream.UnicodeBOM |
UTF16LE_BOM
BOM Marker for UTF 16, little endian.
|
static org.apache.velocity.io.UnicodeInputStream.UnicodeBOM |
UTF32BE_BOM
BOM Marker for UTF 32, big endian.
|
static org.apache.velocity.io.UnicodeInputStream.UnicodeBOM |
UTF32LE_BOM
BOM Marker for UTF 32, little endian.
|
static org.apache.velocity.io.UnicodeInputStream.UnicodeBOM |
UTF8_BOM
BOM Marker for UTF 8.
|
| Constructor and Description |
|---|
UnicodeInputStream(InputStream inputStream)
Creates a new UnicodeInputStream object.
|
UnicodeInputStream(InputStream inputStream,
boolean skipBOM)
Creates a new UnicodeInputStream object.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
String |
getEncodingFromStream()
Read encoding based on BOM.
|
boolean |
isSkipBOM()
Returns true if the input stream discards the BOM.
|
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
protected String |
readEncoding()
This method gets the encoding from the stream contents if a BOM exists.
|
void |
reset() |
static boolean |
sameEncoding(String left,
String right)
Helper function to compare encodings
|
long |
skip(long n) |
public static final org.apache.velocity.io.UnicodeInputStream.UnicodeBOM UTF8_BOM
public static final org.apache.velocity.io.UnicodeInputStream.UnicodeBOM UTF16LE_BOM
public static final org.apache.velocity.io.UnicodeInputStream.UnicodeBOM UTF16BE_BOM
public static final org.apache.velocity.io.UnicodeInputStream.UnicodeBOM UTF32LE_BOM
public static final org.apache.velocity.io.UnicodeInputStream.UnicodeBOM UTF32BE_BOM
public UnicodeInputStream(InputStream inputStream) throws IllegalStateException, IOException
inputStream - The input stream to use for reading.IllegalStateExceptionIOExceptionpublic UnicodeInputStream(InputStream inputStream, boolean skipBOM) throws IllegalStateException, IOException
inputStream - The input stream to use for reading.skipBOM - If this is set to true, a BOM read from the stream is discarded. This parameter should normally be true.IllegalStateExceptionIOExceptionpublic boolean isSkipBOM()
public String getEncodingFromStream()
IllegalStateException - When a problem reading the BOM occured.protected String readEncoding() throws IOException
IOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionInputStream.close()public int available()
throws IOException
available in class InputStreamIOExceptionInputStream.available()public void mark(int readlimit)
mark in class InputStreamreadlimit - InputStream.mark(int)public boolean markSupported()
markSupported in class InputStreamInputStream.markSupported()public int read()
throws IOException
read in class InputStreamIOExceptionInputStream.read()public int read(byte[] b)
throws IOException
read in class InputStreamb - bufferIOExceptionInputStream.read(byte[])public int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamb - bufferoff - offsetlen - lengthIOExceptionInputStream.read(byte[], int, int)public void reset()
throws IOException
reset in class InputStreamIOExceptionInputStream.reset()public long skip(long n)
throws IOException
skip in class InputStreamn - IOExceptionInputStream.skip(long)Copyright © 2000–2021 The Apache Software Foundation. All rights reserved.