根据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]