All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.qcloud.cos.internal.COSStringResponseHandler Maven / Gradle / Ivy

There is a newer version: 5.6.238.2
Show newest version
package com.qcloud.cos.internal;

import java.io.InputStream;

import com.qcloud.cos.http.CosHttpResponse;
import com.qcloud.cos.utils.StringUtils;

public class COSStringResponseHandler extends AbstractCosResponseHandler {

    @Override
    public CosServiceResponse handle(CosHttpResponse response) throws Exception {
        CosServiceResponse cosResponse = parseResponseMetadata(response);

        int bytesRead;
        byte[] buffer = new byte[1024];
        StringBuilder builder = new StringBuilder();
        InputStream content = response.getContent();
        while ((bytesRead = content.read(buffer)) > 0) {
            builder.append(new String(buffer, 0, bytesRead, StringUtils.UTF8));
        }
        cosResponse.setResult(builder.toString());

        return cosResponse;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy