I'm having a little difficult posting a set of data to an HTTPS endpoint. This is what I have so far:
Java Code:
public String postData(String content, String access_token){
		try{
			String data = URLEncoder.encode("body", "UTF-8") + "=" + URLEncoder.encode(content, "UTF-8");
		    data += "&" + URLEncoder.encode("access_token", "UTF-8") + "=" + URLEncoder.encode(access_token, "UTF-8");
			// Create a socket to the host
		    String hostname = "the.domain.com";
		    int port = 443;
		    SocketFactory socketFactory = SSLSocketFactory.getDefault();
		    Socket socket = socketFactory.createSocket(hostname, port);

		    // Send header
		    String path = "/path-to-endpoint";
		    BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), "UTF8"));
		    wr.write("POST "+path+" \r\n");
		    wr.write("Content-Length: "+data.length()+"\r\n");
		    wr.write("Content-Type: application/x-www-form-urlencoded\r\n");
		    wr.write("\r\n");

		    // Send data
		    wr.write(data);
		    wr.flush();

		    // Get response
		    BufferedReader rd = new BufferedReader(new InputStreamReader(socket.getInputStream()));
		    String output = "";
		    String line;
		    while ((line = rd.readLine()) != null) {
		        output += line;
		    }
		    wr.close();
		    rd.close();
		    return output;
		} catch (Exception e) {
			System.out.println(e);
		}
		return "";
	}
The error i'm receiving is:
java.net.SocketException: Software caused connection abort: socket write error
I'd appreciate any suggestions on what i'm doing wrong or on better approaches to this problem.

Thanks.