0
如何讀取從特定的URL一些數據在Android中如何讀取從特定的URL一些數據在Android中
如何讀取從特定的URL一些數據在Android中如何讀取從特定的URL一些數據在Android中
Try this code in your file: USE url = "your url name+filename.jpg,mp3,etc..." FileName = "/sdcard/savefilename" try{ java.io.BufferedInputStream in = new java.io.BufferedInputStream(new java.net.URL(url).openStream()); java.io.FileOutputStream fos = new java.io.FileOutputStream(FileName); java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024); byte[] data = new byte[1024]; int x=0; while((x=in.read(data,0,1024))>=0){ bout.write(data,0,x); } fos.flush(); bout.flush(); fos.close(); bout.close(); in.close(); } catch (Exception ex) { }
您可以使用HttpClient的下載通過URL識別內容。
@user:你想要什麼,請明確提出你的問題,你想解析XML? – 2010-12-14 09:52:32
或Json?或者可能是html本身? – Cristian 2010-12-14 10:16:53