import java.io.File;
import java.io.FileOutputStream;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;

public class ImageDownload {
  public static void main(String[] args) {
    try {
      HttpClient client = new HttpClient();
      File image = new File("test.jpg");
      FileOutputStream fos = new FileOutputStream(image);

      GetMethod method 
        = new GetMethod("http://www.example.org/image.jpg");
      client.executeMethod(method);

      fos.write(method.getResponseBody());
      fos.flush();
      fos.close();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
