cURL equivalent in JAVA

jsoup

The jsoup library fetches a URL as the first step in its HTML scraping and parsing duties.

Document doc = Jsoup.connect("http://en.wikipedia.org/").get();

Exception handling omitted:

HttpURLConnection con = (HttpURLConnection) new URL("https://www.example.com").openConnection();
con.setRequestMethod("POST");
con.getOutputStream().write("LOGIN".getBytes("UTF-8"));
con.getInputStream();

Try Apache Commons Net for network protocols. Free!


I'd use the Commons Http Client. There is a contrib class in the project that allows you to use ssl.

We're using it and it's working well.

Edit: Here's the SSL Guide