de.glossmaker.common.io
Class UnicodeInputStream

Package class diagram package UnicodeInputStream
java.lang.Object
  extended by java.io.InputStream
      extended by de.glossmaker.common.io.UnicodeInputStream
All Implemented Interfaces:
Closeable

public class UnicodeInputStream
extends InputStream

This inputstream will recognize unicode BOM marks and will skip bytes if getEncoding() method is called before any of the read(...) methods.

Author:
Aki Nieminen

Constructor Summary
UnicodeInputStream(InputStream in, String defaultEnc)
           
 
Method Summary
 void close()
           
 String getDefaultEncoding()
           
 String getEncoding()
           
protected  void init()
          Read-ahead four bytes and check for BOM marks.
 int read()
           
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnicodeInputStream

public UnicodeInputStream(InputStream in,
                          String defaultEnc)
Method Detail

getDefaultEncoding

public String getDefaultEncoding()

getEncoding

public String getEncoding()

init

protected void init()
             throws IOException
Read-ahead four bytes and check for BOM marks. Extra bytes are unread back to the stream, only BOM bytes are skipped.

Throws:
IOException

close

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

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException


Copyright © 2010 - 2011 Markus Flingelli. All Rights Reserved.