我从oracle中读出blob类型的数据,但是不知道怎么转化成string请大家帮忙看看,谢谢!
解决方案 »
- 我如何做一个按钮,SQL数据更新后按下这个按钮让JTABLE里边对应的栏目也更新
- jsp使用js 出现您指定的网页无法访问! 错误类型:连接失败 去掉js没报错
- 请高手解决个截字符串出现问号的问题
- JDBC与SQL 最基本的求教一下!!!!谢谢了!!
- 精英?
- 紧急呼救 一个SQL SERVER数据库连接问题
- 新手问题关于APPLET的!
- 数据库问题
- 我运行java时,出了以下的错误
- 求教 InetAddress中isReachable()总是返回false
- 狂晕,很久没来,怎么没有了netbeans版,却只有eclipse版???
- 一个类同时继承了一个类实现了一个接口,如何用一条语句调用接口中的变量?
try {
if (rs.next()) {
Blob blob = rs.getBlob("content");
InputStream is = new BufferedInputStream(blob.getBinaryStream());
try {
File tempFile = File.createTempFile(docId, "", new File(
ServerManager.tempDir));
FileOutputStream fos = new FileOutputStream(tempFile);
try {
byte[] b = new byte[1024];
while (true) {
int i = is.read(b, 0, 1024);
if (i == -1) {
result = tempFile;
break;
}
fos.write(b, 0, i);
}
} finally {
fos.close();
}
} finally {
is.close();
}
}
} finally {
rs.close();
}
Statement st = null;
ResultSet rs = null;
try {
//...获取conn
st = conn.createStatement();
rs = st.executeQuery("select big_bit from blob_test");
while (rs.next())
Blob blob = rs.getBlob(1);
InputStream in = blob.getBinaryStream();
//一般接下来是把in的字节流写入一个文件中,但是你要放进字符串我也就不写那么麻烦的了 String s="";
byte[] buff=new byte[1024];
for(int i=0;(i=in.read(buff))>0;){
s=s+new String(buff);
}
in.close();
}
}