menu
more_vert
MyIfmHttpClient

作者:dayu

e); return responsedata; } finally { if (outputStream != null) { try { outputStream.close(); } catch (IOException e) { log.error("error while using IfmHttpUtil" + e); } } if (inptStream != null) { try { inptStream.close(); } catch (IOException e) { log.error("error while using IfmHttpUtil" + e); } } } return responsedata; } private byte[] getRequestData(String content, String encode) { byte[] result = null; try { if (content != null) result = content.getBytes(encode); } catch (UnsupportedEncodingException e) { log.error("error while using IfmHttpUtil" + e); } return result; } /** * 处理服务器返回结果 * * @param inputStream * 输入流 * @return 返回处理后的String 字符串 */ private String dealResponseResult(InputStream inputStream) { String resultData = null; // 存储处理结果 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byte[] data = new byte[1024]; int len = 0; try { while ((len = inputStream.read(data)) != -1) { byteArrayOutputStream.write(data, 0, len); } resultData = new String(byteArrayOutputStream.toByteArray(), "utf-8"); } catch (IOException e) { log.error("error while using IfmHttpUtil" + e); } return resultData; } /** * 将权限信息放在header中 * * @param headerMapper * @param connection */ private void addHeader(Map<String, String> headerMapper, HttpURLConnection connection) { for (Map.Entry<String, String> entry : headerMapper.entrySet()) { connection.addRequestProperty(entry.getKey(), entry.getValue()); } } }

MyIfmHttpClient

原文地址:http://www.cnblogs.com/tonggc1668/p/7525304.html