if (b.getCharset().equals(ref) || b.getGroup().equals(ref)) {
InputStream prefix = new ByteArrayInputStream(detectionBuffer, b.getHeaderLength(), bufferSize - b.getHeaderLength());
return new InputStreamReader(new ConcatInputStream(prefix, in), b.getCharset());
}
else {
throw new UnsupportedEncodingException("The requested encoding was " + encoding + " but the file contained a BOM for " + b.getCharset().name() + ".");
}
}
else {
InputStream prefix = new ByteArrayInputStream(detectionBuffer, 0, bufferSize);
return new InputStreamReader(new ConcatInputStream(prefix, in), encoding);