title: How can I download Image File from an URL to ByteArray?
body: <p>following is my code:</p>
  
  <pre><code>private byte[] downloadImage(String image_url) {
              byte[] image_blob = null;
              URL _image_url = null;
              HttpURLConnection conn = null;
              InputStream inputStream = null;
              try {
                  _image_url = new URL(image_url);
              } catch (MalformedURLException e) {
                  e.printStackTrace();
              }
              try {
                  conn = (HttpURLConnection) _image_url.openConnection();
  
              } catch (IOException e) {
                  e.printStackTrace();
              }
              conn.setDoInput(true);
              try {
                  conn.connect();
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              conn.setUseCaches(false);
              try {
                  inputStream = conn.getInputStream();
                  inputStream.read(image_blob);
  
              } catch (IOException ex) {
                  ex.printStackTrace();
              } finally {
                  try {
                      inputStream.close();
                  } catch (IOException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
                  conn.disconnect();
              }
              return image_blob;
          }
  </code></pre>
  
  <p>What I am trying to do is to get the byte array of an Image. Use it in a parcel to transfer it to another activity.</p>
  
  <p>Using this code a NullPointerException is reported. Can any one say what is wrong?</p>