Java InetAddress to toDotString(InetAddress ip)

Here you can find the source of toDotString(InetAddress ip)

Description

to Dot String

License

Apache License

Declaration

public static String toDotString(InetAddress ip) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.net.InetAddress;

public class Main {
    public static String toDotString(InetAddress ip) {
        byte[] bytes = ip.getAddress();
        String str = new String();
        for (int i = 0; i < 4; i++) {
            int b = bytes[i];
            if (b < 0)
                b += 256;/* www  .j a v a2  s  . c o m*/
            str += b;
            if (i < 3)
                str += ".";
        }

        return str;
    }
}

Related

  1. inetAddressToThriftBinary(InetAddress inetAddress)
  2. ipv4AddressToInt(InetAddress addr)
  3. str(InetAddress address)
  4. toAddressString(InetAddress ip)
  5. toAddrString(InetAddress ip)
  6. toIntArray(InetAddress addr)
  7. toIpAddrString(final InetAddress addr)
  8. toLong(InetAddress addr)
  9. toLong(InetAddress ip)