@@ -0,0 +1,2432 @@
+package com.alucn.casemanager.server.common.util;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0Aimport java.io.OutputStream;%0Aimport java.net.HttpURLConnection;%0Aimport java.net.MalformedURLException;%0Aimport java.net.ProtocolException;%0Aimport java.net.URL;%0A%0Aimport net.sf.json.JSONObject;%0A%0Apublic class HttpReq %7B%0A%09%0A%09public static JSONObject reqUrl(String httpUrl) %7B%0A%09%09JSONObject infos = new JSONObject();%0A%09%09URL url;%0A%09%09try %7B%0A%09%09%09url = new URL(httpUrl);%0A%09%09%09InputStream inputStream = null;%0A%09%09%09InputStreamReader inputStreamReader = null;%0A%09%09%09BufferedReader reader = null;%0A%09%09%09String tempLine, response = %22%22;%0A%09%09%09HttpURLConnection connection = (HttpURLConnection) url.openConnection();%0A%09%09%09connection.setRequestMethod(%22GET%22);%0A%09%09%09connection.setDoOutput(true);%0A%09%09%09if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) %7B%0A%09%09%09%09inputStream = connection.getInputStream();%0A%09%09%09%09inputStreamReader = new InputStreamReader(inputStream);%0A%09%09%09%09reader = new BufferedReader(inputStreamReader);%0A%09%09%09%09while ((tempLine = reader.readLine()) != null) %7B%0A%09%09%09%09%09response += tempLine;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09infos = JSONObject.fromObject(response);%0A%09%09%7D catch (MalformedURLException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D catch (ProtocolException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%09return infos;%0A%09%7D%0A%09%0A%09%0A%09public static String reqUrl(String httpUrl, String data) %7B%0A%09%09URL url;%0A%09%09String response = %22%22;%0A%09%09try %7B%0A%09%09%09url = new URL(httpUrl);%0A%09%09%09InputStream inputStream = null;%0A%09%09%09InputStreamReader inputStreamReader = null;%0A%09%09%09BufferedReader reader = null;%0A%09%09%09String tempLine;%0A%09%09%09HttpURLConnection connection = (HttpURLConnection) url.openConnection();%0A%09%09%09connection.setRequestMethod(%22POST%22);%0A%09%09%09connection.setDoOutput(true);%0A%09%09%09OutputStream out = connection.getOutputStream();%0A%09%09%09out.write(data.getBytes());%0A%09%09%09out.flush();%0A%09%09%09out.close();%0A%0A%09%09%09if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) %7B%0A%09%09%09%09inputStream = connection.getInputStream();%0A%09%09%09%09inputStreamReader = new InputStreamReader(inputStream);%0A%09%09%09%09reader = new BufferedReader(inputStreamReader);%0A%09%09%09%09while ((tempLine = reader.readLine()) != null) %7B%0A%09%09%09%09%09response += tempLine;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D catch (MalformedURLException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D catch (ProtocolException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%09return response;%0A%09%7D%0A%7D%0A

add http request util