org.riotfamily.common.io
Class UnicodeStreamReader

java.lang.Object
  extended by java.io.Reader
      extended by org.riotfamily.common.io.UnicodeStreamReader
All Implemented Interfaces:
Closeable, Readable

public class UnicodeStreamReader
extends Reader

Reader that uses a Byte Order Mark (BOM) to identify the encoding of the underlying stream. If present, the BOM is removed from the stream.

Since:
7.0
Author:
Felix Gnass [fgnass at neteye dot de]
See Also:
JDK Bug 4508058, Byte Order Mark FAQ

Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
UnicodeStreamReader(InputStream in)
          Creates a new UnicodeStreamReader.
UnicodeStreamReader(InputStream in, String defaultEncoding)
          Creates a new UnicodeStreamReader.
 
Method Summary
 void close()
           
 String getEncoding()
           
 int read(char[] cbuf, int off, int len)
           
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnicodeStreamReader

public UnicodeStreamReader(InputStream in)
                    throws IOException
Creates a new UnicodeStreamReader. If no BOM is found in the stream the default system encoding is used.

Parameters:
in - An InputStream
Throws:
IOException - If an I/O error occurs

UnicodeStreamReader

public UnicodeStreamReader(InputStream in,
                           String defaultEncoding)
                    throws IOException
Creates a new UnicodeStreamReader. If no BOM is found in the stream the given default encoding is used.

Parameters:
in - An InputStream
defaultEncoding - The encoding to be used if no BOM is found
Throws:
IOException - If an I/O error occurs
Method Detail

getEncoding

public String getEncoding()

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in class Reader
Throws:
IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws IOException
Specified by:
read in class Reader
Throws:
IOException