Sample code for 30+ languages & platforms
Java

Wasabi Download String

See more Wasabi Examples

Demonstrates how to download a text Wasabi object to a string variable.

Chilkat Java Downloads

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

public class ChilkatExample {

    public static void main(String[] args) {
        // This example assumes the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        Http http = new Http();

        // Insert your access key here:
        http.setAwsAccessKey("access-key");

        // Insert your secret key here:
        http.setAwsSecretKey("secret-key");

        // Use the endpoint matching the bucket's region.
        http.setAwsEndpoint("s3.us-west-1.wasabisys.com");

        String bucketName = "chilkattest";
        String objectName = "orchard.json";

        // This is the byte representation of the text file downloaded from Wasabi.
        // It must be specified to allow Chilkat to correctly interpret the bytes as characters.
        String charset = "utf-8";

        String fileContents = null;
        try {
            fileContents = http.s3DownloadString(bucketName, objectName, charset);
            System.out.println(fileContents);
            System.out.println("Success.");
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
        }
    }
}