Android 以流的方式读取服务器图片文件

public void getCodeImage(final String path) {
new Thread() {
public void run() {
try {
HttpURLConnection conn = (HttpURLConnection) new URL(path).openConnection();
conn.setConnectTimeout(30 * 1000);
conn.setRequestMethod(“POST”);
InputStream inputStream = conn.getInputStream();
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
mGetImageCode.setImageBitmap(bitmap);
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
}

你可能感兴趣的:(android,android,图片,url,path)