title: Download a file from url and save to memory disk android
body: <p>I have tried to download a file from url and save it to memory cart, but I cant understand what is my wrong, my code is</p>
  
  <pre><code>URL url = new URL(imageURL);
          File file = new File(fileName);
  
          long startTime = System.currentTimeMillis();
          Log.d("ImageManager", "download begining");
          Log.d("ImageManager", "download url:" + url);
          Log.d("ImageManager", "downloaded file name:" + fileName);
          URLConnection ucon = url.openConnection();
          InputStream is = ucon.getInputStream();
          BufferedInputStream bis = new BufferedInputStream(is);
  
          ByteArrayBuffer baf = new ByteArrayBuffer(50);
          int current = 0;
          while ((current = bis.read()) != -1) {
             baf.append((byte) current);
          }
  
          /* Convert the Bytes read to a String. */
          FileOutputStream fos = new FileOutputStream(file);
          fos.write(baf.toByteArray());
          fos.close();
          Log.d("ImageManager", "download ready in"
                          + ((System.currentTimeMillis() - startTime) / 1000)
                          + " sec");
  </code></pre>
  
  <p>but i found the following error in my console</p>
  
  <pre><code>12-27 14:50:01.302: D/EXCEPTION GET:(8062): java.io.FileNotFoundException: /my.jpg (Read-only file system)
  </code></pre>
  
  <p>Actually i dont know what can i do, anyone help please.</p>