Java SQL Clob read(Clob c)

Here you can find the source of read(Clob c)

Description

read

License

Apache License

Declaration

private static String read(Clob c) throws SQLException, IOException 

Method Source Code

//package com.java2s;
/**/*  w w  w . j av  a  2s. c o m*/
 Copyright 2005 Bytecode Pty Ltd.
    
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
    
 http://www.apache.org/licenses/LICENSE-2.0
    
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

import java.io.IOException;
import java.io.Reader;

import java.sql.*;

public class Main {
    public static final int CLOBBUFFERSIZE = 2048;

    private static String read(Clob c) throws SQLException, IOException {
        StringBuilder sb = new StringBuilder((int) c.length());
        Reader r = c.getCharacterStream();
        char[] cbuf = new char[CLOBBUFFERSIZE];
        int n;
        while ((n = r.read(cbuf, 0, cbuf.length)) != -1) {
            sb.append(cbuf, 0, n);
        }
        return sb.toString();
    }
}

Related

  1. getRSClob(Object obj, String def)
  2. getString(Clob c)
  3. getStringFromClob(Clob clob)
  4. isNClob(final Class type)
  5. parseToString(Clob clob)
  6. readStringClob(Clob content)