| java.lang.Object java.io.InputStream org.apache.velocity.io.UnicodeInputStream
UnicodeInputStream | public class UnicodeInputStream extends InputStream (Code) | | This is an input stream that is unicode BOM aware. This allows you to e.g. read
Windows Notepad Unicode files as Velocity templates.
It allows you to check the actual encoding of a file by calling
UnicodeInputStream.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.
author: Aki Nieminen author: Henning P. Schmiedehausen version: $Id: UnicodeInputStream.java 500638 2007-01-27 22:16:10Z henning $ |
Inner Class :final static class UnicodeBOM | |
Field Summary | |
final public static UnicodeBOM | UTF16BE_BOM BOM Marker for UTF 16, big endian. | final public static UnicodeBOM | UTF16LE_BOM BOM Marker for UTF 16, little endian. | final public static UnicodeBOM | UTF32BE_BOM BOM Marker for UTF 32, big endian. | final public static UnicodeBOM | UTF32LE_BOM BOM Marker for UTF 32, little endian. | final public static UnicodeBOM | UTF8_BOM BOM Marker for UTF 8. |
Constructor Summary | |
public | UnicodeInputStream(InputStream inputStream) Creates a new UnicodeInputStream object. | public | UnicodeInputStream(InputStream inputStream, boolean skipBOM) Creates a new UnicodeInputStream object.
Parameters: inputStream - The input stream to use for reading. Parameters: skipBOM - If this is set to true, a BOM read from the stream is discarded. |
UTF16BE_BOM | final public static UnicodeBOM UTF16BE_BOM(Code) | | BOM Marker for UTF 16, big endian. See http://www.unicode.org/unicode/faq/utf_bom.html
|
UTF16LE_BOM | final public static UnicodeBOM UTF16LE_BOM(Code) | | BOM Marker for UTF 16, little endian. See http://www.unicode.org/unicode/faq/utf_bom.html
|
UTF32BE_BOM | final public static UnicodeBOM UTF32BE_BOM(Code) | | BOM Marker for UTF 32, big endian. See http://www.unicode.org/unicode/faq/utf_bom.html
TODO: Does Java actually support this?
|
UTF32LE_BOM | final public static UnicodeBOM UTF32LE_BOM(Code) | | BOM Marker for UTF 32, little endian. See http://www.unicode.org/unicode/faq/utf_bom.html
TODO: Does Java actually support this?
|
UTF8_BOM | final public static UnicodeBOM UTF8_BOM(Code) | | BOM Marker for UTF 8. See http://www.unicode.org/unicode/faq/utf_bom.html
|
UnicodeInputStream | public UnicodeInputStream(InputStream inputStream) throws IllegalStateException, IOException(Code) | | Creates a new UnicodeInputStream object. Skips a BOM which defines the file encoding.
Parameters: inputStream - The input stream to use for reading. |
UnicodeInputStream | public UnicodeInputStream(InputStream inputStream, boolean skipBOM) throws IllegalStateException, IOException(Code) | | Creates a new UnicodeInputStream object.
Parameters: inputStream - The input stream to use for reading. Parameters: skipBOM - If this is set to true, a BOM read from the stream is discarded. This parameter should normally be true. |
getEncodingFromStream | public String getEncodingFromStream()(Code) | | Read encoding based on BOM.
The encoding based on the BOM. throws: IllegalStateException - When a problem reading the BOM occured. |
isSkipBOM | public boolean isSkipBOM()(Code) | | Returns true if the input stream discards the BOM.
True if the input stream discards the BOM. |
readEncoding | protected String readEncoding() throws IOException(Code) | | This method gets the encoding from the stream contents if a BOM exists. If no BOM exists, the encoding
is undefined.
The encoding of this streams contents as decided by the BOM or null if no BOM was found. |
|
|