/** |
* 根据url获取并保存文件 |
* |
* 可获取图片,音频,视频等格式文件 |
* |
*/ |
URL url = new URL( "http://www.baidu.com" ); |
Object o = url.getContent(); |
InputStream ip = (InputStream) o; |
byte [] b = new byte [ 20 ]; |
FileOutputStream fout = new FileOutputStream( "c://baidu.html" ); |
while (ip.read(b) != - 1 ) { |
fout.write(b); |
} |