Java Local Address Get getLocalAddrs()

Here you can find the source of getLocalAddrs()

Description

get Local Addrs

License

Open Source License

Declaration

static public InetAddress[] getLocalAddrs() throws UnknownHostException 

Method Source Code

//package com.java2s;
/*/*from www  .  j  av  a  2  s  .c o m*/
 * ISABEL: A group collaboration tool for the Internet
 * Copyright (C) 2009 Agora System S.A.
 * 
 * This file is part of Isabel.
 * 
 * Isabel is free software: you can redistribute it and/or modify
 * it under the terms of the Affero GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Isabel 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
 * Affero GNU General Public License for more details.
 * 
 * You should have received a copy of the Affero GNU General Public License
 * along with Isabel.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.net.*;

public class Main {
    static public InetAddress[] getLocalAddrs() throws UnknownHostException {

        // Primero sacamos el nombre de la maquina

        String host = InetAddress.getLocalHost().getCanonicalHostName();

        // Ahora cogemos todas las ips

        return InetAddress.getAllByName(host);

    }
}

Related

  1. getLocalAddresses()
  2. getLocalAddresses()
  3. getLocalAddressFromNetworkInterfacesListeningOnPort(int pPort)
  4. getLocalAddressStrings()
  5. getLocalAddressWithMulticast()
  6. getLocalInet4Address()
  7. getLocalInet4Address()
  8. getLocalInternetProtocolAddress()
  9. getLocalMachineAddress()