baos.write(buf, 0, bytesRead);
}
byte[] data = baos.toByteArray();
Document document = new Document();
if (mimeType.equals("text/html")) {
Resource resource = new Resource("http://127.0.0.1/", null, new ContentType(mimeType), data, 0, false);
org.w3c.dom.Document dom = resource.parseHTML();
TextRecord textRecord = new TextRecord("http://127.0.0.1/");
Transformer transformer = TransformerFactory.newInstance().newTransformer();
TextRecordResult result = new TextRecordResult(textRecord, new URIRewriter(), 100, false, document);
transformer.transform(new DOMSource(dom), result);