@Override
    public int read() throws IOException {
      ensureOpen();
      if (next >= length)
        return -1;
      return str.charAt(next++);
    }
Check to make sure that the stream has not been closed
ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathUtil.java