📜  在 com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:251) - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:03.544000             🧑  作者: Mango

代码示例1
url = new URL("http://...");
connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestMethod("POST");

request = new OutputStreamWriter(connection.getOutputStream());
request.write(params);
request.flush();
request.close();
String line;

int status = connection.getResponseCode();
if(status < 400) {

    InputStreamReader isr = new InputStreamReader(connection.getInputStream());
    ...
} else{
    InputStreamReader isr = new InputStreamReader(connection.getErrorStream());
    ...
}