0
Because it is giving nullPointerException. I use Outputstream even 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 realized that you have a problem with the.openConnection url().
You could post the stack trace?
– Math
Could be the protocol, your URL is http and Voce is casting for Httpsurlconnection
– David Schrammel
David, do you know how I can solve this?
– daniel12345smith
I put a possible solution, you need to provide more information about the error...
– David Schrammel