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