create Delete via SSL Connection - Java Network

Java examples for Network:SSL

Description

create Delete via SSL Connection

Demo Code


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;

public class Main{
    static public HttpsURLConnection createDeleteConnection(String urlStr) {
        CheckerUtils.notNullOrEmpty(urlStr, "url");

        try {/* w w  w. ja v  a  2s.  c  om*/
            URL url = new URL(urlStr);
            HttpsURLConnection con = (HttpsURLConnection) url
                    .openConnection();
            con.setRequestMethod("DELETE");
            return con;
        } catch (MalformedURLException e) {
            throw new IllegalStateException(e);
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    }
}

Related Tutorials