Sample code for 30+ languages & platforms
Java

Example: Http.S3_FileExists method

Demonstrates the S3_FileExists 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[])
  {
    CkHttp http = new CkHttp();

    //  Insert your AWS keys here:
    http.put_AwsAccessKey("AWS_ACCESS_KEY");
    http.put_AwsSecretKey("AWS_SECRET_KEY");

    String bucketName = "chilkat.ocean";
    String objectName = "seahorse.jpg";
    http.put_AwsRegion("us-west-2");
    http.put_AwsEndpoint("s3-us-west-2.amazonaws.com");

    int retval = http.S3_FileExists(bucketName,objectName);
    if (retval < 0) {
        System.out.println("Failed to check for the S3 object existence");
        System.out.println(http.lastErrorText());
        return;
        }

    if (retval == 0) {
        System.out.println("The S3 object does not exist.");
        return;
        }

    System.out.println("The S3 object exists.");
  }
}