标签:blog http io os ar java sp 2014 on
============问题描述============
public class HttpAssist { public static String doPost(JSONObject json) throws IOException{ URL postUrl = new URL(Config.url); HttpURLConnection connection = (HttpURLConnection) postUrl.openConnection(); connection.setDoOutput(true); connection.setDoInput(true); connection.setRequestMethod("POST"); connection.setUseCaches(false); connection.connect(); OutputStreamWriter out = new OutputStreamWriter (connection .getOutputStream()); out.write( Config.getParameterName + "=" + json.toString()); out.flush(); out.close(); // flush and close BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(),"utf-8")); String line=""; String res = ""; while ((line = reader.readLine()) != null){ res += line; System.out.println(line); } reader.close(); connection.disconnect(); return res; } }
============解决方案1============
============解决方案2============
HttpURLConnection中connection.getInputStream()报异常FileNotFoundException
标签:blog http io os ar java sp 2014 on
原文地址:http://www.cnblogs.com/yiguobei99/p/4038851.html