Java SQL Clob getStringFromClob(Clob clob)

Here you can find the source of getStringFromClob(Clob clob)

Description

get String From Clob

License

Open Source License

Declaration

public static String getStringFromClob(Clob clob) throws SQLException, IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;

import java.io.Reader;
import java.sql.Clob;
import java.sql.SQLException;

public class Main {
    public static String getStringFromClob(Clob clob) throws SQLException, IOException {
        String returnValue = null;
        Reader reader = null;//from  w w  w  . j  av a 2s . c o m
        try {
            //   Convert CLOB description to String.
            if (clob != null && clob.length() != 0) {
                reader = clob.getCharacterStream();
                int clobSize = (int) clob.length();
                char[] buffer = new char[clobSize];
                reader.read(buffer);
                returnValue = new String(buffer);
                reader.close();
            } else {
            }
        } finally {
            if (reader != null) {
                reader.close();
            }
        }
        return returnValue;
    }
}

Related

  1. convertToString(Object obj)
  2. getClobToString(Clob clob)
  3. getRSClob(Object obj, String def)
  4. getFormattedClobColumn(final InputStream is)
  5. getString(Clob c)
  6. isNClob(final Class type)
  7. parseToString(Clob clob)
  8. read(Clob c)
  9. readStringClob(Clob content)