67,538
社区成员
发帖
与我相关
我的任务
分享
<%@ page contentType='text/html; charset=gbk' language='java'%>
<%@ page import='java.net.*'%>
<%@ page import='java.io.*'%>
<html>
<body>
<br><br><h2><font color=blue>Waiting for loading...</font></h2>
<%
String rfileurl ="http://eleven.freejsp.net/tdy218/md5.jpg";
String target = "D:/myjsp/md5.jpg";
try {
URL url = new URL(rfileurl);
HttpURLConnection con = (HttpURLConnection)url.openConnection();
DataInputStream fin = new DataInputStream(con.getInputStream());
DataOutputStream fos = new DataOutputStream(new FileOutputStream(target));
byte[] buffer = new byte[2*1024*1024];
int length=0;
while((length=fin.read(buffer))>0)
{
fos.write(buffer,0,length);
}
fos.close();
fin.close();
}
catch(Exception e){out.print("发生异常:"+e.getMessage());}
%>
</body>
</html>