Convert CURL commands to Java HttpURLConnection code online

Curl command

Examples: GET - POST - JSON - Basic Auth - Files - Form

CURL to Java HttpURLConnection Online

This tool helps you to generate Java HttpURLConnection code based on CURL Command. Copy and Paste CURL Command and Generate Java HttpURLConnection.

What can you do with CURL to Java HttpURLConnection Converter Online?

  • CURL to Java HttpURLConnection is very unique tool to convert cURL command to Java HttpURLConnection request of Java HttpURLConnection. The input provide by the user's cURL command to generate Java HttpURLConnection Code.
  • This tool saves your time and helps to generate Java HttpURLConnection code with ease.
  • CURL to Java HttpURLConnection works well on Windows, MAC, Linux, Chrome, Firefox, Edge and Safari.

what is CURL?

cURL is an open-source command line tool that downloads files from the web. It supports a variety of protocols, including Java HttpURLConnection, Java HttpURLConnectionS, FTP, SFTP, TFTP, Gopher and others.

How do convert CURL to Java HttpURLConnection code? 

Step1: Paste and convert your CURL requests to Java HttpURLConnection code

Step2: Copy Java HttpURLConnection code

Convert CURL to Java HttpURLConnection example

Java HttpURLConnection Code
import java.util.Scanner;

class Main {

    public static void main(String[] args) throws IOException {
        URL url = new URL("");
        HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();

        InputStream responseStream = httpConn.getResponseCode() / 100 == 2
                ? httpConn.getInputStream()
                : httpConn.getErrorStream();
        Scanner s = new Scanner(responseStream).useDelimiter("\\A");
        String response = s.hasNext() ? : "";