- public static String doHttpJsonByBufferedReader(String getUrl)
- {
- String msg = "";
- try
- {
- URL url = new URL(getUrl);
- BufferedReader r = null;
- URLConnection con = url.openConnection();
- r = new BufferedReader(new InputStreamReader(con.getInputStream(),
- "UTF-8"));
- String sCurrentLine = "";
- while ((sCurrentLine = r.readLine()) != null)
- {
- msg += sCurrentLine;
- }
- r.close();
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- return msg;
- }
- //该片段来自于http://www.codesnippet.cn/detail/0912201514207.html
来源: http://www.codesnippet.cn/detail/0912201514207.html