Java Socket Address Get getAddressRepresentation(final SocketAddress address)

Here you can find the source of getAddressRepresentation(final SocketAddress address)

Description

Represents the address as string

License

Open Source License

Parameter

Parameter Description
address The address

Return

The string that represents the address

Declaration

public static String getAddressRepresentation(final SocketAddress address) 

Method Source Code


//package com.java2s;
/*  Copyright 2010 Ben Ruijl, Wouter Smeenk
    /*from w w  w .j  av  a 2s . com*/
This file is part of Walled In.
    
Walled In is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
    
Walled In is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with Walled In; see the file LICENSE.  If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
    
 */

import java.net.InetSocketAddress;
import java.net.SocketAddress;

public class Main {
    /**
     * Represents the address as string
     * 
     * @param address
     *            The address
     * @return The string that represents the address
     */
    public static String getAddressRepresentation(final SocketAddress address) {
        final InetSocketAddress inetAddr = (InetSocketAddress) address;
        return inetAddr.getAddress().getHostAddress() + "@" + inetAddr.getPort();
    }
}

Related

  1. getAddress(InetSocketAddress address)
  2. getAddress(InetSocketAddress address)
  3. getAddress(SocketAddress address)
  4. getAddress(SocketAddress address)
  5. getAddressFirst(InetSocketAddress inetSocketAddress)
  6. getAddrString(final SocketAddress address)
  7. getAlreadyBoundServerSocket(String address, int port, boolean ssl, boolean useChannels)
  8. getBestAddress(InetSocketAddress addr)
  9. getCanonicalConnectionAddress(InetSocketAddress address)