本文介绍了通过JSP将EXE文件保存在客户端pc中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个代码,用于将我的服务器端的exe文件保存到C:\驱动器中的客户端PC上。

但是,我收到的错误是这样的:





For my code:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.io.*"  %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
String fileName=getServletContext().getRealPath("jdk-6u20-windows-i586.exe");

File f=new File(fileName);

InputStream in = new FileInputStream(f);

BufferedInputStream bin = new BufferedInputStream(in);

DataInputStream din = new DataInputStream(bin);
StringBuffer sb=new StringBuffer();
while(din.available()>0)
    {
    sb.append(din.readByte());
    }

try {
    PrintWriter pw = new PrintWriter(new FileOutputStream("c:/jdk-6u20-windows-i586.exe"));// save file 
    pw.println(sb.toString());
    pw.close();
} catch(IOException e) {
   e.getMessage();
}

in.close();
bin.close();
din.close();
%>
    </body>
</html>



请帮我解决这个问题。如果我想添加一个进度条来显示下载文件的计数%,而不是我在代码中为此做的事情。你能帮助我兄弟吗?


Please help me to solve this problem. And if I want to add a progress bar to display count % for downloading file than what I have to do for this in my code. Can you help me brother?

推荐答案

这篇关于通过JSP将EXE文件保存在客户端pc中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 06:52
查看更多