package com.ultra.control.main;import java.io.File;import java.io.FileOutputStream;import java.io.InputStream;import org.apache.http.HttpResponse;import org.apache.http.StatusLine;import org.apache.http.client.HttpClient;import org.apache.http.client.methods.HttpGet;import org.apache.http.impl.client.CloseableHttpClient;import org.apache.http.impl.client.DefaultHttpClient;import org.apache.http.impl.client.HttpClients;public class HttpUtil { public static void main(String[] args) throws Exception { String url = "http://10.0.64.222/product/2015/201507/20150707/RDCP/medium/SEVP_AOC_RDCP_SLDAS_EBREF_ACHN_L88_PI_20150707090000001.GIF"; CloseableHttpClient httpClient = HttpClients.createDefault(); HttpGet httpGet = new HttpGet(url); HttpResponse httpResponse = httpClient.execute(httpGet); StatusLine statusLine = httpResponse.getStatusLine(); if (statusLine.getStatusCode() == 200) { File xml = new File("d:/sitemap/SEVP_AOC_RDCP_SLDAS_EBREF_ACHN_L88_PI_20150706090000001.GIF"); FileOutputStream outputStream = new FileOutputStream(xml); InputStream inputStream = httpResponse.getEntity().getContent(); byte buff[] = new byte[1024]; int counts = 0; while ((counts = inputStream.read(buff)) != -1) { System.out.println("......."); outputStream.write(buff, 0, counts); } outputStream.flush(); outputStream.close(); } httpClient.close(); System.out.println("success!"); }}