HttpURLConnection.setFollowRedirects(false);
HttpURLConnection con = (HttpURLConnection)new URL(“文件路径”).openConnection();
con.setRequestMethod( "HEAD");
if (con.getResponseCode() == HttpURLConnection.HTTP_OK)
{
System.Out.Println("OK");
}