Example usage for java.net Inet4Address getAddress

List of usage examples for java.net Inet4Address getAddress

Introduction

In this page you can find the example usage for java.net Inet4Address getAddress.

Prototype

public byte[] getAddress() 

Source Link

Document

Returns the raw IP address of this InetAddress object.

Usage

From source file:net.fenyo.gnetwatch.GenericTools.java

/**
 * Converts an IP address to its string representation.
 * @param addr ipv4 address./*  w  w  w. ja  v a 2s .  c  o  m*/
 * @return String ascii representation.
 */
static public String inet4AddressToString(final Inet4Address addr) {
    try {
        byte bytes[] = addr.getAddress();
        return InetAddress.getByAddress(bytes).toString().substring(1);
    } catch (final UnknownHostException ex) {
        log.error("Exception", ex);
    }
    return "";
}

From source file:edu.uga.cs.fluxbuster.clustering.DomainCluster.java

/**
 * Gets the CIDR /24 prefixes of a set of IPv4 addresses
 *
 * @param ips the set of ip addresses/*from   w ww .ja  v a 2 s .  com*/
 * @return the set of /24 prefixes
 */
private Set<InetAddress> getPrefixes24(Set<InetAddress> ips) {
    HashSet<InetAddress> retval = new HashSet<InetAddress>();
    Set<Inet4Address> ipsv4 = IPDiversityCalculator.getV4Ips(ips);
    for (Inet4Address ip : ipsv4) {
        byte[] temp = ip.getAddress();
        temp[3] = 0;
        try {
            retval.add(InetAddress.getByAddress(temp));
        } catch (UnknownHostException e) {
            if (log.isErrorEnabled()) {
                log.error("Error getting CIDR /24 prefix", e);
            }
        }
    }
    return retval;
}

From source file:org.calrissian.mango.types.encoders.lexi.Inet4AddressEncoder.java

@Override
public String encode(Inet4Address value) {
    checkNotNull(value, "Null values are not allowed");
    return encodeHexString(value.getAddress());
}

From source file:org.calrissian.mango.types.encoders.lexi.Inet4AddressReverseEncoder.java

@Override
public String encode(Inet4Address value) {
    checkNotNull(value, "Null values are not allowed");
    return encodeHexString(reverse(value.getAddress()));
}