@@ -0,0 +1,1898 @@
+/*%0A *%0A *  * Copyright 2013 the original author or authors.%0A *  *%0A *  * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A *  * you may not use this file except in compliance with the License.%0A *  * You may obtain a copy of the License at%0A *  *%0A *  *      http://www.apache.org/licenses/LICENSE-2.0%0A *  *%0A *  * Unless required by applicable law or agreed to in writing, software%0A *  * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A *  * See the License for the specific language governing permissions and%0A *  * limitations under the License.%0A *%0A */%0A%0Apackage leap.lang.net;%0A%0Aimport java.net.InetAddress;%0Aimport java.net.NetworkInterface;%0Aimport java.net.SocketException;%0Aimport java.net.UnknownHostException;%0Aimport java.util.Enumeration;%0A%0A/**%0A * find local host%0A *%0A * @author kael.%0A */%0Apublic class InetAddresses %7B%0A    public static InetAddress getLocalHostLANAddress() throws UnknownHostException, SocketException %7B%0A        InetAddress candidateAddress = null;%0A        for(Enumeration ifaces = NetworkInterface.getNetworkInterfaces(); ifaces.hasMoreElements(); ) %7B%0A            NetworkInterface iface = (NetworkInterface) ifaces.nextElement();%0A            for(Enumeration inetAddrs = iface.getInetAddresses(); inetAddrs.hasMoreElements(); ) %7B%0A                InetAddress inetAddr = (InetAddress) inetAddrs.nextElement();%0A                if (!inetAddr.isLoopbackAddress()) %7B%0A                    if (inetAddr.isSiteLocalAddress()) %7B%0A                        return inetAddr;%0A                    %7D else if (candidateAddress == null) %7B%0A                        candidateAddress = inetAddr;%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A        if (candidateAddress != null) %7B%0A            return candidateAddress;%0A        %7D%0A        return InetAddress.getLocalHost();%0A    %7D%0A%7D%0A

add InetAddresses