Sample code for 30+ languages & platforms
Java

Example: Http.QuickGetSb method

Demonstrates the QuickGetSb method.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;
import com.chilkatsoft.chilkat2.StringBuilder;

public class ChilkatExample {

    public static void main(String[] args) {
        Http http = new Http();

        // Send the HTTP GET and return the content in a StringBuilder
        StringBuilder sb = new StringBuilder();
        try {
            http.quickGetSb("https://www.chilkatsoft.com/helloWorld.json", sb);
        } catch (ChilkatException e) {
            if (http.getLastStatus() == 0) {
                // Communications error.  We did not get a response.
                System.out.println(e.getLastErrorText());
            } else {
                System.out.println("Response status code: " + http.getLastStatus());
                System.out.println("Response body error text:");
                System.out.println(sb.getAsString());
            }

            return;
        }

        // The downloaded content:
        System.out.println(sb.getAsString());
        System.out.println("Success");
    }
}