Java SQL Clob parseToString(Clob clob)

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

Description

clob parse to string

License

Apache License

Parameter

Parameter Description
clob java.sql.Clob

Declaration

public static String parseToString(Clob clob) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.BufferedReader;
import java.io.Reader;

import java.sql.Clob;

public class Main {
    /**//from w  ww .  j a v a  2 s . co m
     * clob parse to string
     * @param clob java.sql.Clob
     * @return
     */
    public static String parseToString(Clob clob) {
        return parseToString(clob, null);
    }

    /**
     * clob parse to string
     * @param clob java.sql.Clob
     * @return String
     */
    public static String parseToString(Clob clob, String line_end) {
        if (clob == null)
            return null;

        StringBuffer sb = new StringBuffer();
        Reader is = null;
        BufferedReader br = null;
        try {
            is = clob.getCharacterStream();
            br = new BufferedReader(is);
            String line = null;
            while ((line = br.readLine()) != null) {
                sb.append(line + (line_end == null ? "" : line_end));
            }
        } catch (Exception e) {
            //ignore;
        } finally {
            try {
                br.close();
            } catch (Exception e) {
            }
            try {
                is.close();
            } catch (Exception e) {
            }
        }

        return sb.toString();
    }
}

Related

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