how do you convert an InetAddress to a string?
InetAddres.toStrin() doesn't work
Printable View
how do you convert an InetAddress to a string?
InetAddres.toStrin() doesn't work
Have you tried the toString() method? Notice the g.
What does that mean? Can you show the error message or whatever doesn't work?Quote:
doesn't work
toString() is working perfectly for that, but not as you expecting. I hope that's why you are mess on it.
How did you fine the InteAddress? getByName()? So in that case you get as a host, I mean as hostname literal with / sign. So you have do some manipulation to remove it.
Code:InetAddress inet = InetAddress.getByName("193.125.22.1");
System.out.println(inet.toString());