com.mucommander.io.bom
Class BOMReader

java.lang.Object
  extended by java.io.Reader
      extended by java.io.InputStreamReader
          extended by com.mucommander.io.bom.BOMReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class BOMReader
extends java.io.InputStreamReader

BOMReader is a Reader which provides support for Byte-Order Marks (BOM). A BOM is a byte sequence found at the beginning of a Unicode text stream which indicates the encoding of the text that follows.

This class uses a BOMInputStream for BOM handling and serves a dual purpose:
1) it allows to auto-detect the encoding when a BOM is present in the underlying stream and use it.
2) it allows to discard the BOM from a Unicode stream: the leading bytes corresponding to the BOM are swallowed by the stream and never returned by the read methods.

Author:
Maxence Bernard
See Also:
BOMInputStream

Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
BOMReader(BOMInputStream bomIn, java.lang.String defaultEncoding)
          Creates a new BOMReader using the given BOMInputStream.
BOMReader(java.io.InputStream in)
          Creates a new BOMReader.
BOMReader(java.io.InputStream in, java.lang.String defaultEncoding)
          Creates a new BOMReader.
 
Method Summary
 
Methods inherited from class java.io.InputStreamReader
close, getEncoding, read, read, ready
 
Methods inherited from class java.io.Reader
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

BOMReader

public BOMReader(java.io.InputStream in)
          throws java.io.IOException
Creates a new BOMReader. A BOMInputStream is created on top of the specified InputStream to auto-detect a potential BOM and use the associated encoding. If no BOM is found at the beginning of the stream, UTF-8 encoding is assumed.

Parameters:
in - the underlying InputStream
Throws:
java.io.IOException - if an error occurred while detecting the BOM or initializing this reader.

BOMReader

public BOMReader(java.io.InputStream in,
                 java.lang.String defaultEncoding)
          throws java.io.IOException
Creates a new BOMReader. A BOMInputStream is created on top of the specified InputStream to auto-detect a potential BOM and use the associated encoding. If no BOM is found at the beginning of the stream, the specified default encoding is assumed.

Parameters:
in - the underlying InputStream
defaultEncoding - the encoding used if the stream doesn't contain a BOM
Throws:
java.io.IOException - if an error occurred while detecting the BOM or initializing this reader.

BOMReader

public BOMReader(BOMInputStream bomIn,
                 java.lang.String defaultEncoding)
          throws java.io.UnsupportedEncodingException
Creates a new BOMReader using the given BOMInputStream. If the BOMInputStream does not contain a BOM, the specified default encoding is assumed.

Parameters:
bomIn - the underlying BOMInputStream
defaultEncoding - the encoding used if the stream doesn't contain a BOM
Throws:
java.io.UnsupportedEncodingException - if the encoding associated with the BOM or the default encoding is not supported by the Java runtime


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard