Here you can find the source of getBroadcast(InetAddress address)
public static InetAddress getBroadcast(InetAddress address)
//package com.java2s; //License from project: Open Source License import java.net.*; public class Main { /**/*from w w w. j ava 2 s . c o m*/ * Gets the broadcast address for the network interface identified by the given * address. This will only work if the given address is a local address. It will * return {@code null} if it can't find an interface with the given inet address. */ public static InetAddress getBroadcast(InetAddress address) { NetworkInterface inter = getInterface(address); if (inter != null) { for (InterfaceAddress iaddr : inter.getInterfaceAddresses()) { if (iaddr.getAddress().equals(address)) { return iaddr.getBroadcast(); } } } return null; } /** * Return the Network Interface object that has the given InetAddress configured * on it. Returns {@code null} if there are any errors locating the interface. */ public static NetworkInterface getInterface(InetAddress addr) { try { return NetworkInterface.getByInetAddress(addr); } catch (Exception e) { return null; } } /** * Return the Network Interface object identified with the given name. Returns * {@code null} if there are any errors locating the interface. */ public static NetworkInterface getInterface(String name) { try { return NetworkInterface.getByName(name); } catch (Exception e) { return null; } } }