Java InetAddress remove(InetAddress[] a_, InetAddress b)

Here you can find the source of remove(InetAddress[] a_, InetAddress b)

Description

remove

License

Apache License

Declaration

static final public InetAddress[] remove(InetAddress[] a_, InetAddress b) 

Method Source Code

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

import java.net.InetAddress;

public class Main {
    static final public InetAddress[] remove(InetAddress[] a_, InetAddress b) {
        InetAddress[] a = (InetAddress[]) a_.clone();
        for (int i = 0; i < a.length; i++)
            if (b.equals(a[i])) {
                a[i] = null;/*w w w  . j a  va2s  .c om*/
                break;
            }
        return removeNull(a);
    }

    public final static InetAddress[] removeNull(InetAddress addrs[]) {
        int count = 0;
        for (int i = 0; i < addrs.length; i++)
            if (addrs[i] != null)
                count++;
        InetAddress[] result = new InetAddress[count];
        count = 0;
        for (int i = 0; i < addrs.length; i++)
            if (addrs[i] != null)
                result[count++] = addrs[i];
        return result;
    }
}

Related

  1. newInterfaceAddress(InetAddress inetAddress, short maskLength)
  2. normalizeHostAddress(final InetAddress localHost)
  3. parseInetAddressFromString(String input)
  4. readInetAddress(final DataInput in, final boolean fixedLength)
  5. readInetAddress(final String stringInetAddress)
  6. removeNull(InetAddress addrs[])
  7. serialize(InetAddress endpoint, DataOutput out)
  8. sortKey(InetAddress address, boolean prefer_v6)
  9. toStringWithNoHostname(InetAddress address)