new URL(String spec) throws MalformedURLException : URL « java.net « Java by API






new URL(String spec) throws MalformedURLException

  
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

public class Main {
  public static void main(String[] argv) throws Exception {
    
    URLConnection conn = new URL("http://www.yourserver.com").openConnection();
    conn.setDoInput(true);
    conn.setRequestProperty("Authorization", "asdfasdf");
    conn.connect();

    InputStream in = conn.getInputStream();
  }
}

   
    
  








Related examples in the same category

1.URL: getAuthority()
2.URL: getDefaultPort()
3.URL.getPath()
4.URL: getQuery()
5.URL: getRef()
6.URL: openConnection()
7.URL: openStream()