Java SQL Clob readStringClob(Clob content)

Here you can find the source of readStringClob(Clob content)

Description

read String Clob

License

Mozilla Public License

Parameter

Parameter Description
content a parameter

Exception

Parameter Description
SQLException an exception
IOException an exception

Return

String

Declaration

public static String readStringClob(Clob content) throws SQLException, IOException 

Method Source Code


//package com.java2s;
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import java.io.*;

import java.sql.*;

public class Main {
    /**/* w  ww.  ja  v a  2s  .c  o m*/
     *
     * @param content
     * @return String
     * @throws SQLException
     * @throws IOException
     */
    public static String readStringClob(Clob content) throws SQLException, IOException {
        if (content == null) {
            return null;
        }
        Reader reader = content.getCharacterStream();
        BufferedReader in = new BufferedReader(reader);
        StringBuilder rc = new StringBuilder();
        char[] chars = new char[256];
        int count;
        while ((count = in.read(chars)) > 0) {
            rc.append(chars, 0, count);
        }
        return rc.toString();
    }
}

Related

  1. getString(Clob c)
  2. getStringFromClob(Clob clob)
  3. isNClob(final Class type)
  4. parseToString(Clob clob)
  5. read(Clob c)