Java tutorial
//package com.java2s; /* * Copyright(c) 2015, QuCai, Inc. All rights reserved. * This software is the confidential and proprietary information of QuCai, Inc. * You shall not disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into with QuCai. */ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static Bitmap getImage(String urlpath) throws Exception { Bitmap bitmap = null; URL url = new URL(urlpath); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setConnectTimeout(5 * 1000); if (conn.getResponseCode() == 200) { InputStream inputStream = conn.getInputStream(); bitmap = BitmapFactory.decodeStream(inputStream); } return bitmap; } }