hibernate的clob类型转化成string
/**
* 将Clob转化成字符串
*
* @param clob
* @return
* @throws Exception
*/
public static String clobToString(Clob clob) throws Exception {
StringBuffer buffer = new StringBuffer();
if (clob != null) {
BufferedReader br = null;
try {
Reader r = clob.getCharacterStream(); //将Clob转化成流
br = new BufferedReader(r);
String s = null;
while ((s = br.readLine()) != null) {
buffer.append(s);
}
} catch (Exception e) {
e.printStackTrace(); //打印异常信息
} finally {
if (br != null) {
br.close(); //关闭流
}
}
}
return buffer.toString();
}