Clob转String 博客分类: JavaSE clobstring
程序员文章站
2024-03-06 15:03:32
...
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; }