image download

/**
	 * Download pictures
	 *
	 * @param imageUrl
	 * The address of the picture
	 * @param client
	 * Access HTTPS clients
	 * @return returns whether the download has been completed
	 */
	public boolean saveImage(String imageUrl, DefaultHttpClient client) {
		boolean finish = false;
		if (imageUrl != null) {
			HttpGet imageGet = new HttpGet(imageUrl);
			try {
				HttpResponse execute = client.execute(imageGet);
				HttpEntity entity = execute.getEntity();
				InputStream content = entity.getContent();
				OutputStream outputStream = new FileOutputStream("C:\\Users\\admin\\Desktop\\IMG\\imgage.jpg");
				IOUtils.copy(content, outputStream);
				IOUtils.closeQuietly(content);
				IOUtils.closeQuietly(outputStream);
				finish = true;
			} catch (ClientProtocolException e) {
				e.printStackTrace ();
			} catch (IOException e) {
				e.printStackTrace ();
			}

		}
		System.out.println("Download verification code picture is completed: " + finish);
		return finish;
	}

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326727091&siteId=291194637