Here you can find the source of exists(URL url)
public static boolean exists(URL url) throws IOException
//package com.java2s; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static boolean exists(URL url) throws IOException { HttpURLConnection huc = (HttpURLConnection) url.openConnection(); huc.setRequestMethod("HEAD"); huc.connect();// w w w .j a v a2 s.com return (huc.getResponseCode() == HttpURLConnection.HTTP_OK); } }