Java URL不工作/正在加载
我正在尝试加载URL,但它不起作用,以下是我的代码:
public static void main(String[] args){
try {
URL url = new URL("google.com");
String x = url.openConnection().getContent();
System.out.println(x);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
有人能帮我吗
# 1 楼答案
你可以调用你的可执行文件。例如
try{ java.awt.Desktop.getDesktop().browse(java.net.URI.create("ur url")); } catch(Exception e) {}
也可以创建运行时对象。例如
try{ Runtime r = Runtime.getRuntime(); r.exec("ur exe file path"); } catch(Exception e){ }