try{ URL url=new URL("http://1111.com"); url.openConnection();}catch(Exception e){ System.out.println("链接无效");}System.out.println("链接有效");//如果不能打开链接,自然无效,就会执行Catch程序,否则便是有效,自然程序继续往下走了
打开连接来试试看