以下代码给出“线程“main”java.lang.Error中的异常:未解决的编译问题:url无法解析为变量”错误。命令行参数可以有三四个,所以我用了一个if语句来测试它,但是代码似乎并没有从命令行获取String url。
public static void main(String[] args) throws Exception {
Socket sock = new Socket("kjlkjlkjl", 80);
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream()));
writer.write("GET "+ url +"HTTP/1.1\r\n"
+ "Host: jhkjhkjhkjh\r\n"
+ "Connection: keep-alive\r\n"
+ "\r\n");
}