Here you can find the source of getLinkLocalScopeId()
public static int getLinkLocalScopeId() throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.net.Inet6Address; import java.net.InetAddress; import java.net.NetworkInterface; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Main { public static int getLinkLocalScopeId() throws IOException { for (InetAddress a : getIPAddresses()) { if (a instanceof Inet6Address && a.isLinkLocalAddress()) { return ((Inet6Address) a).getScopeId(); }/*from w w w .j av a2s . c om*/ } throw new IOException("No IPv6 support on this device"); } /** * List all IP addresses of the device, except loopback addresses. * * @return a List of IP addresses * @throws IOException */ public static List<InetAddress> getIPAddresses() throws IOException { List<InetAddress> addresses = new ArrayList<InetAddress>(); List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface intf : interfaces) { List<InetAddress> addrs = Collections.list(intf.getInetAddresses()); for (InetAddress a : addrs) { if (a.isLoopbackAddress()) { continue; } addresses.add(a); } } return addresses; } }