Example usage for org.apache.commons.io.input BOMInputStream BOMInputStream

List of usage examples for org.apache.commons.io.input BOMInputStream BOMInputStream

Introduction

In this page you can find the example usage for org.apache.commons.io.input BOMInputStream BOMInputStream.

Prototype

public BOMInputStream(InputStream delegate, boolean include, ByteOrderMark... boms) 

Source Link

Document

Constructs a new BOM InputStream that detects the specified BOMs and optionally includes them.

Usage

From source file:org.terems.webz.internals.FileDownloaderWithBOM.java

public FileDownloaderWithBOM(WebzInputStreamDownloader downloader, String defaultEncoding)
        throws IOException, WebzException {

    this.bomIn = (BOMInputStream) new BOMInputStream(downloader.getInputStream(), false, ALL_BOMS);
    this.downloader = new FileDownloader(downloader.getFileSpecific(), bomIn);
    ByteOrderMark bom = bomIn.getBOM();/*from   w ww.  j  a  va 2s . c  o m*/

    if (bom == null) {
        actualEncoding = defaultEncoding;
        actualNumberOfBytes = downloader.getFileSpecific().getNumberOfBytes();
    } else {
        actualEncoding = bom.getCharsetName();
        actualNumberOfBytes = downloader.getFileSpecific().getNumberOfBytes() - bom.length();
    }
    reader = new InputStreamReader(bomIn, actualEncoding);
}