79810951

Date: 2025-11-06 07:41:36
Score: 2
Natty:
Report link

@ADyson I'm using HttpURLConnection

url = new URL(urladr);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type",
        "application/x-www-form-urlencoded");
connection.setConnectTimeout(14000);
connection.setReadTimeout(60000);
connection.setRequestProperty("Content-Language", "fa-IR");
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(
        connection.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();

//Get Response
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer response = new StringBuffer();
while ((line = rd.readLine()) != null)
    response.append(line);

rd.close();
res = response.toString();
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @ADyson
  • Self-answer (0.5):
  • Looks like a comment (1):
  • Low reputation (0.5):
Posted by: hamid