Clob转String
程序员文章站
2022-06-18 19:56:45
...
java.sql.Clob转String
public static String clob2String(Object clobObj) {
if (clobObj != null && clobObj instanceof Clob) {
Clob clob = (Clob)clobObj;
String reString = "";
try {
Reader is = clob.getCharacterStream();
// 得到流
BufferedReader br = new BufferedReader(is);
String s = br.readLine();
StringBuffer sb = new StringBuffer();
while (s != null) {
//执行循环将字符串全部取出付值给StringBuffer由StringBuffer转成STRING
sb.append(s);
s = br.readLine();
}
reString = sb.toString();
} catch (Exception e) {
log.error("transfer clob to string error!" + e);
}
return reString;
}
return null;
}