关键代码:
try {
String str=Chat.getJt().getText().toString();//获取输入内容
String[] ipstr=str.split("[.]");
byte[] by=new byte[4];
for(int i=0;i<4;i++){
int m=Integer.parseInt(ipstr[i]);
byte b=(byte)(m&0xff);
by[i]=b;
}
InetAddress inet=InetAddress.getByAddress(by);
String pc=inet.getHostName();
} catch (UnknownHostException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}