Last active
April 26, 2018 14:58
-
-
Save danielnorberg/773357c0dfaa78e8755b207e7ae5bef3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
public class Main { | |
public static void main(String[] args) throws IOException { | |
final HttpURLConnection connection = (HttpURLConnection) new URL("http://www.google.com").openConnection(); | |
System.err.println(connection.getRequestMethod() + " " + connection.getURL()); | |
System.err.println("response = " + connection.getResponseCode() + " " + connection.getResponseMessage()); | |
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { | |
String s; | |
while ((s = reader.readLine()) != null) { | |
System.err.println(s); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET http://www.google.com | |
Exception in thread "main" java.lang.reflect.InvocationTargetException | |
at java.lang.Throwable.<init>(Throwable.java:310) | |
at java.lang.Exception.<init>(Exception.java:102) | |
at java.lang.ReflectiveOperationException.<init>(ReflectiveOperationException.java:89) | |
at java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:72) | |
at com.oracle.svm.reflect.proxies.Proxy_43_Main_main.invoke(Unknown Source) | |
at java.lang.reflect.Method.invoke(Method.java:498) | |
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:199) | |
at Lcom/oracle/svm/core/code/CEntryPointCallStubs;.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0) | |
Caused by: java.lang.AssertionError: Should not here | |
at java.lang.Throwable.<init>(Throwable.java:265) | |
at java.lang.Error.<init>(Error.java:70) | |
at java.lang.AssertionError.<init>(AssertionError.java:58) | |
at java.lang.AssertionError.<init>(AssertionError.java:74) | |
at sun.util.logging.LoggingSupport.ensureAvailable(LoggingSupport.java:76) | |
at sun.util.logging.LoggingSupport.isLoggable(LoggingSupport.java:114) | |
at sun.util.logging.PlatformLogger$JavaLoggerProxy.isLoggable(PlatformLogger.java:656) | |
at sun.util.logging.PlatformLogger.isLoggable(PlatformLogger.java:270) | |
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1147) | |
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050) | |
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984) | |
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564) | |
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492) | |
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480) | |
at Main.main(Main.java:12) | |
... 4 more |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment