Code example for HttpEntity

Methods: getContent

0
      final org.apache.http.StatusLine line = response.getStatusLine();
      if (line.getStatusCode() != 200) 
        return null; 
 
       final HttpEntity entity = response.getEntity();
       return (entity != null) ? entity.getContent() : null;
    } // fetchTileFromUrl 
     
    private byte[] loadTileByteArray(final InputStream in) throws IOException
    { 
      final ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
      final OutputStream out = new BufferedOutputStream(dataStream, StreamUtils.IO_BUFFER_SIZE);
      try { 
        StreamUtils.copy(in, out);
        out.flush();
        return dataStream.toByteArray();
      } 
      finally { 
        StreamUtils.closeStream(in);
        StreamUtils.closeStream(out);
      } // finally