你这样写试试:try {
  InetAddress addr=InetAddress.getByName(null);
} catch(IOException ioe) {
  System.out.println(ioe.toString());
}

解决方案 »

  1.   

    (补充错误信息)unreptorted exception:java.net.unknownhostexception;must be caught
    or declare to be thrown
      

  2.   

    try {
      InetAddress addr=InetAddress.getByName(null);
    } catch(IOException ioe) {
      System.out.println(ioe.toString());
    } catch(UnknownHostException uhe) {
      e.printStackTrace();
    }or
    }catch(Excepiton e) {
      System.out.println(e.toString());
    }
      

  3.   

    没问题啊,返回的是本机地址,127.0.0.1 (localhost)宜昌是应该截获的