Friday, 15 January 2010

download - How to load XML file online and process? -



download - How to load XML file online and process? -

i want create android app rss reader. load xml file particular link http://kalaerkantho.com/rss.xml. after downloading know how parse it. question how download first can process downloaded file.

try this:

private static void downloadfile(string url, string filepath) { seek { file outputfile = new file(filepath); url u = new url(url); urlconnection conn = u.openconnection(); int contentlength = conn.getcontentlength(); datainputstream stream = new datainputstream(u.openstream()); byte[] buffer = new byte[contentlength]; stream.readfully(buffer); stream.close(); dataoutputstream fos = new dataoutputstream(new fileoutputstream(outputfile)); fos.write(buffer); fos.flush(); fos.close(); } catch(filenotfoundexception e) { return; // swallow 404 } grab (ioexception e) { return; // swallow 404 } }

adapted this answer.

file download

No comments:

Post a Comment