Here you can find the source of existsURL_bak(String url)
Parameter | Description |
---|---|
url | the URL to check |
@Deprecated public static boolean existsURL_bak(String url)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.net.*; public class Main { /**//from w w w .j a v a 2 s. c o m * Check if the specified URL exists. * @param url the URL to check * @return true if the URL exists */ @Deprecated public static boolean existsURL_bak(String url) { HttpURLConnection.setFollowRedirects(false); HttpURLConnection conn = null; boolean SUCCESS = false; try { conn = (HttpURLConnection) new URL(url).openConnection(); conn.connect(); //Try to open the stream, if it doesn't exist it will cause an exception. DataInputStream ins = new DataInputStream( new BufferedInputStream(conn.getInputStream())); ins.close(); conn.disconnect(); SUCCESS = true; } catch (FileNotFoundException e) { } catch (Exception e) { e.printStackTrace(); } finally { if (conn != null) conn.disconnect(); } return SUCCESS; } }