jzhua2006 发表于 2013-1-27 04:44:34

根据url 下载文件

public String download() {
try {
URL url = new URL("http://jzhua.iteye.com/rss");

URLConnection conn = url.openConnection();
InputStream is = conn.getInputStream();
byte[] bts = new byte;
ByteArrayOutputStream bout = new ByteArrayOutputStream();
FileOutputStream fout = new FileOutputStream("c:\\test.xml");
int n;
while ((n = is.read(bts)) != -1) {
fout.write(bts, 0, n);
fout.flush();
bts = new byte;
}
} catch (Exception ex) {
ex.printStackTrace();
}

return "err";
}
页: [1]
查看完整版本: 根据url 下载文件