苏强的专栏

做最优秀的自己

原创 根据URL从服务器端复制文件到本地java代码收藏

新一篇: 使用FileChannel复制文件 | 旧一篇: 超链接中文传值问题解决

 
  1. URL url = new URL(“http://localhost:8080/AriadneServer”);
  2. HttpURLConnection connection =(HttpURLConnection)url.openConnection();
  3. DataInputStream in = new DataInputStream(connection.getInputStream());
  4. DataOutputStream out=new DataOutputStream(new FileOutputStream(“D:\\suqiang\\to.txt”));
  5. byte[] buffer = new byte[4096];
  6. int count = 0;
  7. while ((count = in.read(buffer)) > 0) {
  8.     out.write(buffer, 0, count);
  9. }
  10. out.close();
  11. in.close();

发表于 @ 2008年09月24日 17:44:00|评论(loading...)|收藏

新一篇: 使用FileChannel复制文件 | 旧一篇: 超链接中文传值问题解决

评论:没有评论。

发表评论  


当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
Csdn Blog version 3.1a
Copyright © 苏强