1. 程式人生 > >json解析工具類

json解析工具類

//解析json
public static  String  url(String uu){

        try {
            URL hh=new URL(uu);
           HttpURLConnection connection = (HttpURLConnection) hh.openConnection();
            InputStream stream = connection.getInputStream();
            BufferedReader bb=new BufferedReader(new InputStreamReader(stream));
            StringBuffer ssss=new 
StringBuffer(); String line=null; while ((line=bb.readLine())!=null){ ssss.append(line); } Log.e("+++++",ssss.toString()); return ssss.toString(); } catch (MalformedURLException e) { e.printStackTrace(); } catch
(IOException e) { e.printStackTrace(); } return null; } //解析圖片 public static Bitmap img(String uu){ try { URL hh=new URL(uu); HttpURLConnection connection = (HttpURLConnection) hh.openConnection(); InputStream stream = connection.getInputStream(); Bitmap bitmap = BitmapFactory.decodeStream
(stream); return bitmap; } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }