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

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

Description

minus

License

Apache License

Declaration

static final public InetAddress[] minus(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[] minus(InetAddress[] a_, InetAddress[] b) {
        InetAddress[] a = (InetAddress[]) a_.clone();
        for (int i = 0; i < b.length; i++)
            for (int j = 0; j < a.length; j++)
                if (b[i].equals(a[j]))
                    a[j] = null;/*from  ww w. ja  v a  2  s. c o  m*/

        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. inetAddressesComparator(final boolean sameHost)
  2. inetAddressesCompare(final InetAddress[] addresses1, final InetAddress[] addresses2)
  3. inetAddressFromThriftString(String ipAddress)
  4. inetAddressGt(InetAddress a, InetAddress b)
  5. inetAddrToByteArray(InetAddress a)
  6. newInterfaceAddress(InetAddress inetAddress, short maskLength)
  7. normalizeHostAddress(final InetAddress localHost)
  8. parseInetAddressFromString(String input)
  9. readInetAddress(final DataInput in, final boolean fixedLength)