试着建立http://IP:4567/foldername/1234?abc=xyz.我不太了解它,但我在下面写了从谷歌搜索的代码:
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
public class MyUrlConstruct {
public static void main(String a[]){
try {
String protocol = "http";
String host = "IP";
int port = 4567;
String path = "foldername/1234";
URL url = new URL (protocol, host, port, path);
System.out.println(url.toString()+"?");
} catch (MalformedURLException ex) {
ex.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我能够建立URL http://IP:port/foldername/1234?.我被困在查询部分.请帮助我前进.