Java URL Exist exists(URL url)

Here you can find the source of exists(URL url)

Description

exists

License

Open Source License

Declaration

public static boolean exists(URL url) throws IOException 

Method Source Code

//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);
    }
}

Related

  1. exists(String fileorUrl)
  2. exists(String url)
  3. exists(URL url)
  4. exists(URL url)
  5. existsHttp(String URLName)
  6. existsURL(String url)
  7. existsURL_bak(String url)