code: public static void sendPostData(HttpURLConnection conn, String encodedData) throws IOException {
  
          StreamManager sm = new StreamManager();
  
          try {
  
              conn.setDoOutput(true);
              conn.setRequestMethod("POST");
              if (conn.getRequestProperty("Content-Type") == null) {
                  conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
              }
              if (encodedData != null) {
                  if (conn.getRequestProperty("Content-Length") == null) {
                      conn.setRequestProperty("Content-Length", String.valueOf(encodedData.getBytes("UTF-8").length));
                  }
                  DataOutputStream out = new DataOutputStream(sm.handle(conn.getOutputStream()));
                  out.write(encodedData.getBytes());
                  out.close();
              }
          } finally {
              sm.closeAll();
          }
      }
docs: Submits http post data to an HttpURLConnection.
  
  @param conn teh connection
  @param encodedData the encoded data to be sent
  @throws IOException on any connection