json解析工具類
阿新 • • 發佈:2019-01-10
//解析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=newStringBuffer(); 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; }