My Android-app have always presented the DNS-Server(s) with brackets / leading slashes like:

How can we get rid of these unnecessary characters ?
String myIp2Dns1:
String myIp2Dns1 = String.valueOf (LinkProp.getDnsServers()) ;
Log:
Log.d("myDnsInfo - Domain - ", "Domain = " + LinkProp.getDomains());
D/myDnsInfo: dns = [/10.0.2.3]
Solution:
Manipulation of String myIp2Dns1:
myIp2Dns1 = myIp2Dns1.replaceAll("[\\[\\](){}\"^/+\"]","");
This command removes brackets / slashes / backslashes from the String.
The output looks much better now:

You must be logged in to post a comment.