日期:2014-05-20 浏览次数:21346 次
InputStream String2InputStream(String str) { ByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes()); return stream; }
------解决方案--------------------
Blob blob=rs.getBlob("CONTENT");
BufferedReader BlobStream = new BufferedReader(Blob.getCharacterStream());
StringBuffer stringBuffer = new StringBuffer();
int nchars = 0;
char[] buffer = new char[10];
while((nchars = BlobStream.read(buffer)) != -1 )
stringBuffer.append(buffer, 0, nchars);
BlobStream.close();
strDbText = Util.strTrim(stringBuffer.toString());
方法二:
BufferedReader reader = new BufferedReader(Blob.getCharacterStream());
String bb=reader.readLine();
while(bb!=null){
content += bb;
bb = reader.readLine();
}
------解决方案--------------------
在你hibernate的实体bean里的那个String字段上加上一个@Blob注解就行了...