title: Get Images from website
body: <p>I need to download all images from a website to which I have username and password.
  Say, website url is 
  <a href="http://example.co.in/images/Photos/ABC123.jpg" rel="nofollow">http://example.co.in/images/Photos/ABC123.jpg</a>
  in such a way there many images, my requirement is to download all images.
  What can be done in Java, C++ or any programming language ?
  Sample code will be helpful.
  Thanks</p>
  
  <p>Using following code to get image from Google website</p>
  
  <pre><code>import java.io.BufferedInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.FileOutputStream;
  import java.io.InputStream;
  import java.net.URL;
  
  class Test {
  public static void main(String args[]) throws Exception {
      System.out.println("Hello World");
  
      URL url = new URL("http://www.google.co.in/images/google_favicon_128.png");
      InputStream in = new BufferedInputStream(url.openStream());
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      byte[] buf = new byte[1024];
      int n = 0;
      while (-1 != (n = in.read(buf))) {
          out.write(buf, 0, n);
      }
      out.close();
      in.close();
      byte[] response = out.toByteArray();
  
      FileOutputStream fos = new FileOutputStream("C://ABC//google1.jpg");
      fos.write(response);
      fos.close();
  
  }}
  </code></pre>
  
  <p>Now I need help where I don't know name of images say all images with extension .jpg (*.jpg) and it should store in my folder as 1.jpg, 2.jpg and so on.
  So how to get count of number of images and how to access their names in <a href="http://www.google.co.in/images/" rel="nofollow">http://www.google.co.in/images/</a></p>