Code example for BufferedInputStream

Methods: decodeStream, close

0
			// http://blog.donnfelker.com/2010/04/29/android-odd-error-in-defaulthttpclient/ 
			if (!url.startsWith("http://") && !url.startsWith("https://"))
				url = "http://" + url;
			 
			is = fetch(url);
			bis = new BufferedInputStream(is);
			bmp = BitmapFactory.decodeStream(bis);
		} catch (MalformedURLException e) {
			Log.e(TAG, "Bad ad URL", e);
		} catch (IOException e) {
			Log.e(TAG, "Could not get remote ad image", e);
		} finally { 
			try { 
				if( is != null )
					is.close();
				if( bis != null )
					bis.close();
			} catch (IOException e) {
				Log.w(TAG, "Error closing stream.");
			} 
		} 
		return bmp;