ByteBuffer contentInOctets = page.getContent();
InputSource input = new InputSource(new ByteArrayInputStream(contentInOctets.array(),
contentInOctets.arrayOffset() + contentInOctets.position(), contentInOctets.remaining()));
EncodingDetector detector = new EncodingDetector(conf);
detector.autoDetectClues(page, true);
detector.addClue(sniffCharacterEncoding(contentInOctets), "sniffed");
String encoding = detector.guessEncoding(page, defaultCharEncoding);
metadata.set(Metadata.ORIGINAL_CHAR_ENCODING, encoding);
metadata.set(Metadata.CHAR_ENCODING_FOR_CONVERSION, encoding);