// -1 in case of error static int returnCodeHttpHEAD(String url) { url = absoluteURL(url); HttpURLConnection conn = null; InputStream in = null; try { conn = (HttpURLConnection) new URL(url).openConnection(); conn.setRequestMethod("HEAD"); conn.setRequestProperty("X-No-Cookies", "1"); in = conn.getInputStream(); ret conn.getResponseCode(); } catch (IOException e) { ret -1; } finally { closeURLConnection(conn, in); } }