package etcom.servlet; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.servlet.http.HttpServletRequest; public class IoToJsonUtils { public static String getIoToJson(HttpServletRequest request,String code){ String jsonString = null; try { InputStream in = request.getInputStream(); InputStreamReader isr = new InputStreamReader(in,code); BufferedReader reader = new BufferedReader(isr); String inputString = null; StringBuffer stringBuffer = new StringBuffer(); while ((inputString = reader.readLine()) != null) { stringBuffer.append(inputString); } reader.close(); jsonString = stringBuffer.toString(); System.out.println(jsonString); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return jsonString; } }
时间: 2024-10-09 08:04:45