Sample code for 30+ languages & platforms
Java

Example: Http.QuickGetSb method

Demonstrates the QuickGetSb method.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

    CkHttp http = new CkHttp();

    //  Send the HTTP GET and return the content in a StringBuilder
    CkStringBuilder sb = new CkStringBuilder();
    success = http.QuickGetSb("https://www.chilkatsoft.com/helloWorld.json",sb);
    if (http.get_LastMethodSuccess() == false) {
        if (http.get_LastStatus() == 0) {
            //  Communications error.  We did not get a response.
            System.out.println(http.lastErrorText());
            }
        else {
            System.out.println("Response status code: " + http.get_LastStatus());
            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");
  }
}