java http client

There are many situations, when java client needs to respond to the server. One can use advantage of the Apache HttpComponents, download binary, and start to use it. Here is simple example

HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://localhost/");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
int l;
byte[] tmp = new byte[2048];
while ((l = != -1) {
This entry was posted in workday. Bookmark the permalink.

Leave a Reply