This topic describes how to use Alibaba Cloud SDK for Java to call DescribeDisks to obtain disk information.


Before you begin, make sure that you have completed the following:
  • To use Alibaba Cloud SDK for Java, you must have an Alibaba Cloud account and an AccessKey pair. You can create and view your AccessKey pair on the AccessKey Management page in the Alibaba Cloud Console.
  • You have installed Alibaba Cloud SDK for Java. For SDK version details, visit Alibaba Cloud SDK.
        <! -- -->
        <! -->

Sample code

This topic uses the following sample code as an example:
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.FormatType;
import com.aliyuncs.ecs.model.v20140526.*;
 public class DescribeDisks {

        private static final String ACCESS_KEY = "<your-access-key>";
        private static final String ACCESS_SECRET = "<your-access-key_Secret>";
        private static IAcsClient client = null;

        static {
            // Create a profile
            IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", ACCESS_KEY, ACCESS_SECRET);
            // Create an Acs client
            client = new DefaultAcsClient(profile);

        public static FormatType describeDisks(FormatType formatType) {
            // Create a request
            DescribeDisksRequest request = new DescribeDisksRequest();
            try {
                // Obtain returned content
                return client.doAction(request).getHttpContentType();
                // Obtain returned object
                //return client.getAcsResponse(request);
            } catch (ServerException e) {
                return null;
            } catch (ClientException e) {
                return null;

        public static void main(String[] args) {