Because it is giving nullPointerException. I use the same OutPutStream to send to the server?
public void envia(String minhastring) {
HttpURLConnection conn = null;
URL url = null;
try {
url = new URL(
"http://minhaURL");
conn = (HttpsURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
OutputStreamWriter wr = new OutputStreamWriter(
conn.getOutputStream());
wr.write(minhastring);
wr.flush();
} catch (IOException e) {
System.out.println("Erro ao se conectar com o servidor");
e.printStackTrace();
} finally {
conn.disconnect();
}
}
When I debugged, I noticed that you have a problem with url.openConnection ().