try {
URL url = new URL("http://dantri.com.vn/xa-hoi.rss");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.connect();
InputStream is = new BufferedInputStream(url.openStream());
OutputStream fos = new FileOutputStream("/sdcard/xa-hoi.rss");
byte[] buffer = new byte[1024];
int bufferLenght = 0;
while((bufferLenght = is.read(buffer)) != -1){
fos.write(buffer, 0, bufferLenght);
}
fos.close();
fos.flush();
is.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}
LogCat: 03-05 05:11:35.620: W/System.err(3437): java.io.FileNotFoundException: http://m.dantri.com.vn/xa-hoi.rss。
这个问题是 url "dantri.com.vn/xa-hoi.rss" 更改为 "m.dantri.com.vn/xa-hoi.rss" 请帮助我!谢谢大家。