cURL equivalent in JAVA cURL equivalent in JAVA java java

cURL equivalent in JAVA


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();


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


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();