Check HTTP Image path if valid
<p>I have a question in Java how can I check if an image http path is valid or existing?</p>

<p>For example:<br>
This image is existing.
<a href="http://g0.gstatic.com/ig/images/promos/homepage_home.png" rel="nofollow">http://g0.gstatic.com/ig/images/promos/homepage_home.png</a></p>

<p>But this one is not.
<a href="http://sampledomain.com/images/fake.png" rel="nofollow">http://sampledomain.com/images/fake.png</a></p>

<p>I would like to make a logic such that:</p>

<pre><code>If(image is existing)
 - do this
Else
 - do others
</code></pre>

<p>Thanks</p>

<p><strong>UPDATE:</strong>
Tried it with this code that I got while googling:</p>

<pre><code>import java.awt.Image;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
public class TestImage {
      public static void main(String[] arg){
          Image image = null;
          try {
              URL url = new URL("http://g0.gstatic.com/ig/images/promos/homepage_home.png");
              image = ImageIO.read(url);
          } catch (IOException e) {
              System.out.println("Error");
          }
      }
}
</code></pre>

<p>But I always get an error...I am not sure if this is possible.. Any other thoughts?</p>
