Example usage for org.apache.http.util EntityUtilsHC4 toByteArray

List of usage examples for org.apache.http.util EntityUtilsHC4 toByteArray

Introduction

In this page you can find the example usage for org.apache.http.util EntityUtilsHC4 toByteArray.

Prototype

public static byte[] toByteArray(final HttpEntity entity) throws IOException 

Source Link

Document

Read the contents of an entity and return it as a byte array.

Usage

From source file:at.bitfire.davdroid.webdav.WebDavResource.java

public void get(String acceptedMimeTypes) throws URISyntaxException, IOException, HttpException, DavException {
    HttpGetHC4 get = new HttpGetHC4(location);
    get.addHeader("Accept", acceptedMimeTypes);

    @Cleanup/*from  www  . j a  v a2s  .c o m*/
    CloseableHttpResponse response = httpClient.execute(get, context);
    checkResponse(response);

    HttpEntity entity = response.getEntity();
    if (entity == null)
        throw new DavNoContentException();

    properties.contentType = ContentType.get(entity);
    content = EntityUtilsHC4.toByteArray(entity);
}

From source file:com.granita.icloudcalsync.webdav.WebDavResource.java

public void get(String acceptedMimeTypes) throws URISyntaxException, IOException, HttpException, DavException {
    HttpGetHC4 get = new HttpGetHC4(location);
    get.addHeader("Accept", acceptedMimeTypes);

    @Cleanup//  w w w.  j av a 2 s  . com
    CloseableHttpResponse response = httpClient.execute(get, context);
    checkResponse(response);

    HttpEntity entity = response.getEntity();
    if (entity == null)
        throw new DavNoContentException();

    content = EntityUtilsHC4.toByteArray(entity);
}