while ((count = stream.read(buf, 0, buf.length)) != -1) {
bw.writeChars(new String(buf, 0, count));
}
stream.close();
} else if (document instanceof String) {
bw.writeChars((String) document);
} else if (document instanceof Reader) {
char[] buf = new char[1024 * 8];
int count = 0;
while ((count = ((Reader) document).read(buf, 0, buf.length)) != -1) {