<%
String fileName = "bb.doc".toString();
//打开数据库
ResultSet result=null;
String Sql=null;
PreparedStatement prestmt=null;
DBstep.iDBManager2000 DbaObj=new DBstep.iDBManager2000();
DbaObj.OpenConnection();
//取得数据库中的数据
Sql="select * from list order by date desc";
result=DbaObj.ExecuteQuery(Sql);
result.next();
//将数据库中的数据读到流中
InputStream in =result.getBinaryStream("body");
//设置输出的格式
response.reset();
response.setContentType("application/Msword");
response.addHeader("Content-Disposition","attachment; filename=\"" + fileName + "\"");
//循环取出流中的数据
byte[] b = new byte[1024];
int len;
while((len=in.read(b)) >0)
response.getOutputStream().write(b,0,len);
in.close();
%>
String fileName = "bb.doc".toString();
//打开数据库
ResultSet result=null;
String Sql=null;
PreparedStatement prestmt=null;
DBstep.iDBManager2000 DbaObj=new DBstep.iDBManager2000();
DbaObj.OpenConnection();
//取得数据库中的数据
Sql="select * from list order by date desc";
result=DbaObj.ExecuteQuery(Sql);
result.next();
//将数据库中的数据读到流中
InputStream in =result.getBinaryStream("body");
//设置输出的格式
response.reset();
response.setContentType("application/Msword");
response.addHeader("Content-Disposition","attachment; filename=\"" + fileName + "\"");
//循环取出流中的数据
byte[] b = new byte[1024];
int len;
while((len=in.read(b)) >0)
response.getOutputStream().write(b,0,len);
in.close();
%>
oracle.sql.BLOB myBlob = ( (oracle.jdbc.driver.OracleResultSet) rs).getBLOB("full_file"); // step 3: get the chunk size of the LOB from the LOB object
int chunkSize = myBlob.getChunkSize(); // step 4: create a buffer to hold a chunk of data retrieved from
// the LOB object
byte[] byteBuffer = new byte[chunkSize]; // step 5: create a file object
String saveFile = "c:\\car.jpg" ;
File myFile = new File(saveFile); // step 6: create output stream objects to write the LOB contents
// to the new file
FileOutputStream myFileOutputStream =
new FileOutputStream(myFile); // step 7: get the length of the LOB contents from the LOB object
long blobLength = myBlob.length(); // step 8: while the end of the LOB contents has not been reached,
// read a chunk of data from the LOB into the buffer,
// and write the buffer contents to the file
for (
long position = 1;
position <= blobLength;
position += chunkSize
) { // read a chunk of data from myBlob using the getBytes() method
// and store it in the buffer
int bytesRead =
myBlob.getBytes(position, chunkSize, byteBuffer); // write the buffer contents to the file
myFileOutputStream.write(byteBuffer); } // end of for // step 9: close the stream objects
myFileOutputStream.close();
if(rs.next()){
title=(String)rs.getString("title");
oracle.jdbc.driver.OracleResultSet ors =(oracle.jdbc.driver.OracleResultSet)rs;
oracle.sql.BLOB news1= (oracle.sql.BLOB) ors.getBlob("news");
int hits=(int)rs.getInt("hits");
if(news1==null || news1.length()==0){
description = "<font size=2 color=red>文章内容为空</font>";
}else{
description=news1.getSubString((long)1,(int)news1.length());
description=using.encode(description);
}
用一个servlet调用这个bean,然后获取文件名,然后在重定向到这个文件以上步骤对于文件名为英文的文件没有问题,可是对于文件名为中文的文件就不行了:存储成中文文件名的文件后,在servlet中转向到该文件,则报告找不到该文件,后来将文件名的字符串改为UTF8后,结果显示了该文件所在文件夹的全部文件列表有可以显示中文名文件内容的方法吗?