java程序,修改DNS地址。 因为我是搞测试的,经常需要切换测试环境,也就是说需要更改DNS的设置以便连到不同的DNS SERVER. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 以下是一段显示IP地址的程序,不知要显示并修改DNS的话应该怎么写。import java.net.*;public class NetTool{ InetAddress myIPaddress=null; InetAddress myServer=null; public static void main(String[] args){ NetTool mytool; mytool=new NetTool(); System.out.println("Your host IP is:"+mytool.getMyIP()); System.out.println("The Server IP is:"+mytool.getServerIP()); } public InetAddress getMyIP(){ try{ myIPaddress=InetAddress.getLocalHost(); }catch(UnknownHostException e){} return (myIPaddress); } public InetAddress getServerIP(){ try{ myServer=InetAddress.getByName("www.abc.com"); }catch(UnknownHostException e){} return (myServer); } } http://www.csdn.net/Expert/TopicView1.asp?id=927920谢谢 几段问题代码,请求仙人指点 怎么让这段代码出异常 请问如何把java.awt.Image的对象转换成FileInputStream对象,谢谢各人高人 有趣的代码! 请教水仙花数的程序? socket相关问题 eclipse下无法通信 菜鸟问题 简单的面试题!!! 导入了指定的不可见类型 那位高手看看如何解决关于java时间问题 如果我要在iis中访问servlet,什么插件好使 请问再java中怎样定义动态数组?
public class NetTool{
InetAddress myIPaddress=null;
InetAddress myServer=null;
public static void main(String[] args){
NetTool mytool;
mytool=new NetTool();
System.out.println("Your host IP is:"+mytool.getMyIP());
System.out.println("The Server IP is:"+mytool.getServerIP());
}
public InetAddress getMyIP(){
try{
myIPaddress=InetAddress.getLocalHost();
}catch(UnknownHostException e){}
return (myIPaddress);
}
public InetAddress getServerIP(){
try{
myServer=InetAddress.getByName("www.abc.com");
}catch(UnknownHostException e){}
return (myServer);
}
}
谢谢