Java实现Clob类型转String
程序员文章站
2022-06-18 20:22:17
...
public String clobToString(Clob clob) throws Exception {
String re = "";
Reader is = null;
BufferedReader br = null;
try {
// 得到流
is = clob.getCharacterStream();
br = new BufferedReader(is);
String s = br.readLine();
StringBuffer sb = new StringBuffer();
// 执行循环将字符串全部取出付值给StringBuffer由StringBuffer转成STRING
while (s != null) {
sb.append(s);
s = br.readLine();
}
re = sb.toString();
} catch (Exception e) {
e.printStackTrace();
}finally {
if (is != null) {
is.close();
}
if (br != null) {
br.close();
}
}
return re;
}
String clobString = clob.getSubString(1, (int) clob.length());
String blobString = new String(blob.getBytes(1, (int) blob.length()),"GBK");
下一篇: linux常见命令