第一种:
import java.io.BufferedInputStream;
import java.io.IOException;
import java.sql.Clob;
import java.sql.SQLException;
/**
* 数据库处理对象
*/
public final class DatabaseHelper {
/**
* 将Clob类型转换为String类型
*
* @param clob 存放内容的变量
* @return 返回Clob类型的String类型内容.
*/
public static String changeClobToString(Clob clob) throws IOException,
SQLException {
BufferedInputStream bi = new BufferedInputStream(clob.getAsciiStream());
int len = (int) clob.length();
byte[] by = new byte[len];
int i;
while (-1 != (i = bi.read(by, 0, by.length))) {
bi.read(by, 0, i);
}
String clobValue = new String(by);
bi.close();
return clobValue;
}
}
第二种:
Clob clob = details[i].getHelpBody();
String content = clob.getSubString((long)1,(int)clob.length());