附件下载的问题,请哪位大侠帮助下啊,急死人了啊,谢谢啊!!!
ResultSet rs = st.executeQuery("select letter_bookx from r_staff_letter_info where id="+idstr);
try{
if (rs.next()) {
java.sql.Blob blob = rs.getBlob(1);
InputStream ins = blob.getBinaryStream();
// 用文件模拟输出流
File file = new File("d:\\output.txt");
OutputStream fout = new FileOutputStream(file);
// 下面将BLOB数据写入文件
byte[] b = new byte[1024];
int len = 0;
while ((len = ins.read(b)) != -1) {
fout.write(b, 0, len);
} // 依次关闭
fout.close();
ins.close();
}
}catch(Exception e){
e.printStackTrace();
}finally{
conn.commit();
conn.close();
}
请问下这个WHILE循环为什么进不去执行呢?
while ((len = ins.read(b)) != -1) {
fout.write(b, 0, len);
}
麻烦了啊!!