根据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[2048];
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[2048];
}
} catch (Exception ex) {
ex.printStackTrace();
}

return "err";
}

你可能感兴趣的:(C++,c,xml,C#)