package com.util.clob;
import java.io.BufferedReader;
import java.io.Reader;
import java.sql.Clob;
/**
* 将数据库Clob类型数据转 字符串工具类
* @author lijx
*
*/
public class ClobUtil {
/**
*
* @param clob
* @return
* @throws Exception
*/
public static String clobToString(Clob clob) throws Exception{
Reader is = null;
BufferedReader br = null;
String string = null;
try {
// 得到流
is = clob.getCharacterStream();
br = new BufferedReader(is);
String s = br.readLine();
StringBuffer sb = new StringBuffer();
while (s != null) {
sb.append(s);
s = br.readLine();
}
string = sb.toString();
return string;
} catch (Exception e) {
throw new Exception("Clob Translate To String Exception:"+e.getMessage());
} finally {
try{
if(is!=null){
is.close();
}
if(br!=null){
br.close();
}
}catch(Exception e){
e.printStackTrace();
}
}
}
}
Clob转换工具
最新推荐文章于 2024-05-30 00:06:34 发布