求救:怎么样同过java编程把internet上的网站(包括图片)下载到本地??给点思路有分!!! 是别人站点上的东西,如http://news.sina.com.cn上的图片等。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.io.*;import java.net.*;import java.util.Vector;public class Xianzai { public static void main(String arg[]) { String urlStr="http://news.sina.com.cn/My Pictures/1.jpg"; String destination="e:/lchb/1.jpg"; Vector bytes; try { byte[]chunk=new byte[4096]; FileOutputStream out=new FileOutputStream(destination); URL url=new URL(urlStr); InputStream is=url.openStream(); System.out.println("is.getclass ().getName()"); int count; while ((count=is.read(chunk))>=0) { byte[] t=new byte[count]; System.arraycopy(chunk,0,t,0,count); out.write(t); } out.close(); } catch(Exception ex) { System.out.println("Xianzai.main():"+ex); } } } 在页面上编写代码并显示结果 图片有href连接怎么除掉下划线? 两个关于spring的问题。 javaWeb 600小时的工期 如CSDN一样;每天登陆不管多少次;给加一次分 关于大系统中的用户会话 急!使用jxl写入多个sheet的excel文件的问题! 创建一个复选框和一个选择框,当选中复选框时,显示选择框,不选中时,隐藏选择框,怎么实现? 一份基于xml的web合同管理系统毕业设计!请各位前辈进来讨论一下! hibernate关联查询出现问题 请教https登录的做法 急用啊 有高手吗:如果编程创建证书?
import java.net.*;
import java.util.Vector;public class Xianzai
{
public static void main(String arg[])
{
String urlStr="http://news.sina.com.cn/My Pictures/1.jpg";
String destination="e:/lchb/1.jpg";
Vector bytes;
try
{
byte[]chunk=new byte[4096];
FileOutputStream out=new FileOutputStream(destination);
URL url=new URL(urlStr);
InputStream is=url.openStream();
System.out.println("is.getclass ().getName()");
int count;
while ((count=is.read(chunk))>=0)
{
byte[] t=new byte[count];
System.arraycopy(chunk,0,t,0,count);
out.write(t);
}
out.close();
}
catch(Exception ex)
{
System.out.println("Xianzai.main():"+ex);
}
}
}