1.联网通过url获取json文件
String url = HttpRequest.getInstance()."字段"2.解析url
public static String getResponseString(String path) {
DefaultHttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(path);
String response = null;
try {
response = client.execute(request, new BasicResponseHandler());
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return response;
}3.通过返回的结果保存到本地
File file = FileUtil.creatSDDir(Constant.SDPATH+"");
public static void saveTOshanhuazhiyuanzheSDCards(String result, File file)
throws Exception {
File file2 = FileUtil.creatSDFile(Constant.SDPATH
+ "");
OutputStream os = new FileOutputStream(file2);
os.write(result.getBytes());
os.close();
997

被折叠的 条评论
为什么被折叠?



