\/\*.*\*\/ 正则表达式 notepad++
发布时间:2020-12-14 06:45:42 所属栏目:百科 来源:网络整理
导读:在notepad++ 里使用这样的替换 ctrl+h /*.**/ 可以替换掉 /* 里面任何 */ 引用 /* */ public static String requestPost(String params,HttpURLConnection httpConn,String encode) /* */ throws Exception /* */ { /* 161 */ String result = ""; /* 162
在notepad++ 里使用这样的替换 ctrl+h
/*.**/ 可以替换掉 /* 里面任何 */
引用
/* */ public static String requestPost(String params,HttpURLConnection httpConn,String encode) /* */ throws Exception /* */ { /* 161 */ String result = ""; /* 162 */ OutputStream output = null; /* 163 */ OutputStreamWriter writer = null; /* 164 */ InputStream input = null; /* 165 */ InputStreamReader iReader = null; /* 166 */ BufferedReader bReader = null; /* 167 */ StringBuffer rBuffer = new StringBuffer(); /* 168 */ String line = null; /* 169 */ logger.debug("请求地址:" + httpConn.getURL().getPath()); /* 170 */ logger.debug("请求参数:" + params); /* */ try { /* 172 */ output = httpConn.getOutputStream(); /* 173 */ writer = new OutputStreamWriter(output); /* 174 */ writer.write(params); /* 175 */ writer.flush(); /* 176 */ input = httpConn.getInputStream(); /* 177 */ iReader = new InputStreamReader(input,encode); /* 178 */ bReader = new BufferedReader(iReader); /* 179 */ while ((line = bReader.readLine()) != null) { /* 180 */ rBuffer.append(line); /* */ } /* 182 */ result = rBuffer.toString(); /* 183 */ logger.debug("请求结果:" + result); /* 184 */ return result; /* */ } catch (Exception e) { /* 186 */ logger.error(e.getMessage(),e); /* 187 */ return ""; /* */ } finally { /* 189 */ if (output != null) output.close(); /* 190 */ if (writer != null) writer.close(); /* 191 */ if (input != null) input.close(); /* 192 */ if (iReader != null) iReader.close(); /* 193 */ if (bReader != null) bReader.close(); /* 194 */ httpConn.disconnect(); /* */ } /* */ }
引用
public static String requestPost(String params,String encode) throws Exception { String result = ""; OutputStream output = null; OutputStreamWriter writer = null; InputStream input = null; InputStreamReader iReader = null; BufferedReader bReader = null; StringBuffer rBuffer = new StringBuffer(); String line = null; logger.debug("请求地址:" + httpConn.getURL().getPath()); logger.debug("请求参数:" + params); try { output = httpConn.getOutputStream(); writer = new OutputStreamWriter(output); writer.write(params); writer.flush(); input = httpConn.getInputStream(); iReader = new InputStreamReader(input,encode); bReader = new BufferedReader(iReader); while ((line = bReader.readLine()) != null) { rBuffer.append(line); } result = rBuffer.toString(); logger.debug("请求结果:" + result); return result; } catch (Exception e) { logger.error(e.getMessage(),e); return ""; } finally { if (output != null) output.close(); if (writer != null) writer.close(); if (input != null) input.close(); if (iReader != null) iReader.close(); if (bReader != null) bReader.close(); httpConn.disconnect(); } }
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |