如题!!
我在网上搜了一个相关的程序可是老是会弹出一个安装word的窗口而且说找不到安装文件,我把程序贴出来大家看看那里有问题,麻烦各位高手帮帮忙!
<%
String image_id ="2" ;
int imglen=0;
try {
response.setContentType("application/msword;charset=gb2312");
ResultSet rs = Conn.executeQuery("select chp_content from chapter where chp_id=2");
//Conn是我的一个链接数据库的文件
if(rs.next())
{
oracle.sql.BLOB m_blob=(oracle.sql.BLOB) rs.getBlob("chp_content");
int length=(int) m_blob.length();
imglen=length;
BufferedInputStream bis=new BufferedInputStream(m_blob.getBinaryStream());
byte[] l_buffer = new byte[1024];
int l_nbytes = 0;
javax.servlet.ServletOutputStream op = response.getOutputStream();
File newfile=new File("d:/new.doc");
FileOutputStream nn=new FileOutputStream(newfile);
while((l_nbytes =bis.read(l_buffer))!= -1){
op.write(l_buffer,0, l_nbytes);
nn.write(l_buffer,0, l_nbytes);
}
op.close();
nn.close();
}
System.out.println("文档长度:"imglen);
rs.close();
Conn.close();
}
catch(Exception e) {
System.out.println(imglen);
System.out.println(e.getMessage());
}
%>
我在网上搜了一个相关的程序可是老是会弹出一个安装word的窗口而且说找不到安装文件,我把程序贴出来大家看看那里有问题,麻烦各位高手帮帮忙!
<%
String image_id ="2" ;
int imglen=0;
try {
response.setContentType("application/msword;charset=gb2312");
ResultSet rs = Conn.executeQuery("select chp_content from chapter where chp_id=2");
//Conn是我的一个链接数据库的文件
if(rs.next())
{
oracle.sql.BLOB m_blob=(oracle.sql.BLOB) rs.getBlob("chp_content");
int length=(int) m_blob.length();
imglen=length;
BufferedInputStream bis=new BufferedInputStream(m_blob.getBinaryStream());
byte[] l_buffer = new byte[1024];
int l_nbytes = 0;
javax.servlet.ServletOutputStream op = response.getOutputStream();
File newfile=new File("d:/new.doc");
FileOutputStream nn=new FileOutputStream(newfile);
while((l_nbytes =bis.read(l_buffer))!= -1){
op.write(l_buffer,0, l_nbytes);
nn.write(l_buffer,0, l_nbytes);
}
op.close();
nn.close();
}
System.out.println("文档长度:"imglen);
rs.close();
Conn.close();
}
catch(Exception e) {
System.out.println(imglen);
System.out.println(e.getMessage());
}
%>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货