// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.net.*;

public class PageChecker {
    public static boolean test(String urlstr) {
        boolean retval = false;
        try {
            URL url = new URL(urlstr);
            HttpURLConnection con = (HttpURLConnection) url.openConnection();
            con.connect();
            int status = con.getResponseCode();
            if (status == HttpURLConnection.HTTP_OK) {
                retval = true;
            } else {
                retval = false;
            }
            con.disconnect();
        } catch (Exception e) {
            retval = false;
        }
        return retval;
    }
    public static void main(String[] args) {
        System.out.println(PageChecker.test("http://arne/"));
        System.out.println(PageChecker.test("http://arne/notexist"));
        System.out.println(PageChecker.test("http://noexist/"));
    }
}
