public static boolean exists(String URLName)
{
HttpURLConnection con = null;
boolean isTrue = false;
try
{
HttpURLConnection.setFollowRedirects(false);
con = (HttpURLConnection) new URL(URLName).openConnection();
con.setRequestMethod("HEAD");
isTrue = (con.getResponseCode() == HttpURLConnection.HTTP_OK);
}
catch (Exception e)
{
isTrue = false;
}
finally
{
if (!isTrue)
{
System.out.println(URLName + " is not exist");
}
if (con != null)
{
con.disconnect();
}
return isTrue;
}
}