Skip to content

Instantly share code, notes, and snippets.

View alexfu's full-sized avatar

Alex Fu alexfu

View GitHub Profile
@alexfu
alexfu / ImageLoader.java
Created April 5, 2013 14:17
Downloading an image from the network using HttpURLConnection
private void fetchImageFromNetwork() {
InputStream input = null;
OutputStream output = null;
HttpURLConnection urlConnection = null;
byte[] buffer = new byte[100*1024];
try {
URL url = new URL(imageUrl);
urlConnection = (HttpURLConnection) url.openConnection();
input = urlConnection.getInputStream();
output = new FileOutputStream(path);