我正在尝试从文本文件中获取IP地址,因此当我使用以下代码时,它确实无法工作..
System.out.println("get = "+get); //get is where the ip address is stored after reading from file and it is successfully received as well
Socket client=new Socket(get,5000);
我甚至通过InetAddress尝试了同样的事情,如下所示..但它也不起作用。
InetAddress ik= InetAddress.getByName(get);
Socket client=new Socket(ik,5000);
但是当我手动提供ip时,它可以正常工作。我不明白我错在哪里?
String get="192.168.1.224";
答案 0 :(得分:2)
简单地:
System.out.println("get = "+get.trim());
Socket client=new Socket(get,5000);