Java Socket Address Get addressToString(InetSocketAddress address, Boolean useIpAddress)

Here you can find the source of addressToString(InetSocketAddress address, Boolean useIpAddress)

Description

address To String

License

Apache License

Declaration

public static String addressToString(InetSocketAddress address, Boolean useIpAddress) 

Method Source Code

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

import java.net.*;

public class Main {
    public static String addressToString(InetSocketAddress address, Boolean useIpAddress) {
        if (useIpAddress) {
            return "http://" + address.getAddress().getHostAddress() + ":" + address.getPort();
        } else {//ww  w  .  j  av a 2  s  .c om
            return "http://" + address.getAddress().getHostName() + ":" + address.getPort();
        }
    }
}

Related

  1. address2string(InetSocketAddress isa)
  2. addressIn(SocketAddress address, String ip)
  3. addressLabel(SocketAddress localAddress, SocketAddress remoteAddress)
  4. addressMapToString( Map> map)
  5. addressToString(InetSocketAddress a)
  6. asString(SocketAddress socketAddress)
  7. cast2SocketAddress(String addr)
  8. compareAddresses(InetSocketAddress addr1, InetSocketAddress addr2)
  9. convertToHostString(SocketAddress hostAddress)