Java Utililty Methods URL Post

List of utility methods to do URL Post

Description

The list of methods to do URL Post are organized into topic(s).

Method

booleanpostToUrl(String page)
post To Url
URL url;
URLConnection urlConn;
DataOutputStream printout;
DataInputStream input;
try {
    url = new URL(page);
    urlConn = url.openConnection();
    urlConn.setDoInput(true);
...
StringpostUrl(URL url, String data)
post Url
OutputStreamWriter wr = null;
BufferedReader rd = null;
try {
    URLConnection conn = url.openConnection();
    conn.setDoOutput(true);
    wr = new OutputStreamWriter(conn.getOutputStream());
    wr.write(data);
    wr.flush();
...
voidwritePostRequest(URLConnection connection, String postRequestBody, String contentType)
write Post Request
connection.setDoOutput(true); 
if (contentType != null) {
    connection.setRequestProperty("Content-Type", contentType);
try (DataOutputStream out = new DataOutputStream(connection.getOutputStream())) {
    out.writeBytes(postRequestBody);
StringxmlPost(String urlStr, String xmlInfo)
xml Post
try {
    URL url = new URL(urlStr);
    URLConnection con = url.openConnection();
    con.setDoOutput(true);
    con.setRequestProperty("Pragma:", "no-cache");
    con.setRequestProperty("Cache-Control", "no-cache");
    con.setRequestProperty("Content-Type", "text/xml");
    OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream());
...
URLConnectionwriteString(URLConnection connection, String string)
write String
writeString(connection.getOutputStream(), string);
return connection;