void (Reader reader, String systemID, int lineNr) { int bufSize = 2048; int sizeRead = 0; StringBuilder str = new StringBuilder(bufSize); char[] buf = new char[bufSize]; for (; ; ) { if (sizeRead >= bufSize) { bufSize *= 2; str.ensureCapacity(bufSize); } int size; try { size = reader.read(buf); } catch (IOException e) { break; } if (size < 0) { break; } str.append(buf, 0, size); sizeRead += size; } IXMLElement elt = prototype.createElement(null, systemID, lineNr); elt.setContent(str.toString()); if (!stack.isEmpty()) { IXMLElement top = stack.peek(); top.addChild(elt); } }