protected String getClobString ( Clob clobObject , String encoding ) throws IOException , SQLException , UnsupportedEncodingException { if ( null == clobObject ) { return "" ; } InputStream in = clobObject . getAsciiStream ( ) ; Reader read = new InputStreamReader ( in , encoding ) ; StringWriter write = new StringWriter ( ) ; String result = null ; try { int c = - 1 ; while ( ( c = read . read ( ) ) != - 1 ) { write . write ( c ) ; } write . flush ( ) ; result = write . toString ( ) ; } finally { closeStream ( write ) ; closeStream ( read ) ; //should we close the ascii stream from database? or is it handled by connection // closeStream(in); } return result ; }
turns clob into a string