Here you can find the source of getResponseCode(URI uri)
public static int getResponseCode(URI uri) throws MalformedURLException, IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; public class Main { public static int getResponseCode(final URL url) throws IOException { HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.connect();//from w ww. j a v a 2s .c o m return connection.getResponseCode(); } public static int getResponseCode(URI uri) throws MalformedURLException, IOException { return getResponseCode(uri.toURL()); } }