문제

As the title states, I'm attempting to simply send a HTTP request to a webserver with URLConnection, but when I attempt to run the script, it does not send the request, nor does it give me an error.

Code:

public static URLConnection connection;
new URL("http://website.com/dostuff.php?whatever=" + whatever).openConnection();
도움이 되었습니까?

해결책

URL.openConnection does not create the connection immediately. It only connects after you call a method that requires a connection. For example:

URL url = ...;
InputStream in = url.openStream(); // connection happens here
// you can now read the output from in
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top