title: Most efficient solution for reading CLOB to String, and String to CLOB in Java?
body: <p>I have a big CLOB (more than 32kB) that I want to read to a String, using StringBuilder. How do I do this in the most efficient way? I can not use the "int length" constructor for StringBuilder since the lenght of my CLOB is longer than a "int" and needs a "long" value.</p>
  
  <p>I am not that confortable with the Java I/O classes, and would like to get some guidance.</p>
  
  <p><b>Edit</b> - <i>I have tried with this code for clobToString():</i></p>
  
  <pre><code>private String clobToString(Clob data) {
      StringBuilder sb = new StringBuilder();
      try {
          Reader reader = data.getCharacterStream();
          BufferedReader br = new BufferedReader(reader);
  
          String line;
          while(null != (line = br.readLine())) {
              sb.append(line);
          }
          br.close();
      } catch (SQLException e) {
          // handle this exception
      } catch (IOException e) {
          // handle this exception
      }
      return sb.toString();
  }
  </code></pre>