inputstream.jsp

来自「jsp与数据库开发的全部代码」· JSP 代码 · 共 22 行

JSP
22
字号
1  <%@ page contentType="text/html;charset=gb2312"%>
2  <%@ page import="java.io.*"%>
3  <%@ page import="java.net.*"%>
4  <%
5    int bytesum=0;
6    int byteread=0;
7    //下载文件的链接地址
8    URL url = new URL("http://game.china.com/zh_cn/download/cheats/hero3_cool.zip");
9    URLConnection conn = url.openConnection();
10    InputStream inStream = conn.getInputStream();
11    //下载文件的存放路径
12    FileOutputStream fs=new FileOutputStream("c:/xx.zip");
13    byte[]  buffer =new  byte[1444];
14      while ((byteread=inStream.read(buffer))!=-1)
15      {
16         out.println("<DT><B>"+byteread+"</B></DT>");
17         bytesum+=byteread;
18         //System.out.println(bytesum);
19         fs.write(buffer,0,byteread);
20       }
21  %>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?