title: How to save image on specific folder in java
body: <p>how to save an image in a certain Directory ?</p>
  
  <pre><code>private void saveImage(String imageUrl, String destinationFile) throws Exception
  {
  
      URL url = new URL(imageUrl);
      InputStream is = url.openStream();
      OutputStream os = new FileOutputStream(destinationFile);
  
      byte[] b = new byte[2048];
      int length;
  
      while ((length = is.read(b)) != -1) {
          os.write(b, 0, length);
      }
  
      is.close();
      os.close();
  
  }
  </code></pre>
  
  <p>The preceding code does not work properly. Any Suggestions.?</p>