Commit 49dfc466db13a7ddef254bc6c16e7ebaa26c449d
1 parent
f28ae77af2
Exists in
master
and in
8 other branches
修改新电子病历
Showing 1 changed file with 11 additions and 7 deletions
platform-common/src/main/java/com/lyms/platform/common/utils/HttpRequest.java
View file @
49dfc46
... | ... | @@ -206,9 +206,9 @@ |
206 | 206 | } |
207 | 207 | |
208 | 208 | public static String sendPost(String url, String param,String auth) { |
209 | - PrintWriter out = null; | |
210 | 209 | BufferedReader in = null; |
211 | 210 | String result = ""; |
211 | + OutputStream outputStream=null; | |
212 | 212 | try { |
213 | 213 | URL realUrl = new URL(url); |
214 | 214 | // 打开和URL之间的连接 |
215 | 215 | |
216 | 216 | |
... | ... | @@ -226,11 +226,11 @@ |
226 | 226 | conn.setRequestProperty("Method","POST"); |
227 | 227 | conn.setRequestProperty("Charset", "UTF-8"); |
228 | 228 | // 获取URLConnection对象对应的输出流 |
229 | - out = new PrintWriter(conn.getOutputStream()); | |
229 | + outputStream = conn.getOutputStream(); | |
230 | 230 | // 发送请求参数 |
231 | - out.print(param); | |
231 | + outputStream.write(param.getBytes("UTF-8")); | |
232 | 232 | // flush输出流的缓冲 |
233 | - out.flush(); | |
233 | + outputStream.flush(); | |
234 | 234 | // 定义BufferedReader输入流来读取URL的响应 |
235 | 235 | in = new BufferedReader( |
236 | 236 | new InputStreamReader(conn.getInputStream())); |
237 | 237 | |
... | ... | @@ -245,15 +245,19 @@ |
245 | 245 | //使用finally块来关闭输出流、输入流 |
246 | 246 | finally{ |
247 | 247 | try{ |
248 | - if(out!=null){ | |
249 | - out.close(); | |
250 | - } | |
251 | 248 | if(in!=null){ |
252 | 249 | in.close(); |
253 | 250 | } |
254 | 251 | } |
255 | 252 | catch(IOException ex){ |
256 | 253 | ex.printStackTrace(); |
254 | + } | |
255 | + if(null!=outputStream){ | |
256 | + try { | |
257 | + outputStream.close(); | |
258 | + }catch (Exception e){ | |
259 | + e.printStackTrace(); | |
260 | + } | |
257 | 261 | } |
258 | 262 | } |
259 | 263 | return result; |