Java Resource Load getResponseCode(URI uri)

Here you can find the source of getResponseCode(URI uri)

Description

get Response Code

License

Open Source License

Declaration

public static int getResponseCode(URI uri) throws MalformedURLException, IOException 

Method Source Code


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

Related

  1. getResourceUrl(final String resourcePath)
  2. getResourceUrl(String path, String extension, ClassLoader loader)
  3. getResourceURL(String resourcePath)
  4. getResourceUrl(String resourcePath)
  5. getResourceUsingFileStreams(InputStream source)