/** * Returns a substring. * * @param pos the position (the first character is at position 1) * @param length the number of characters * @return the string */ public String getSubString(long pos, int length) throws SQLException { try { if (isDebugEnabled()) { debugCode("getSubString(" + pos + ", " + length + ");"); } checkClosed(); if (pos < 1) { throw DbException.getInvalidValueException("pos", pos); } if (length < 0) { throw DbException.getInvalidValueException("length", length); } StringWriter writer = new StringWriter(Math.min(Constants.IO_BUFFER_SIZE, length)); Reader reader = value.getReader(); try { IOUtils.skipFully(reader, pos - 1); IOUtils.copyAndCloseInput(reader, writer, length); } finally { reader.close(); } return writer.toString(); } catch (Exception e) { throw logAndConvert(e); } }