JAvaローカルエリアネットワーク内IPの取得


詳細
JAva、ローカルエリアネットワーク内のすべてのipをどのように取得しますか?
ローカルエリアネットワーク内のすべてのipをどのようにスキャンしますか?
コードは次のとおりです.
package com.jn.lan;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.util.StringTokenizer;
import java.util.Vector;

import com.common.util.SystemHWUtil;
import com.string.widget.util.ValueWidget;

public class LANIP {
	public static InetAddress[] getAllOnline() {
		// TODO Auto-generated method stub
		Vector v = new Vector(50);
		try {
			// Process process1 =
			// Runtime.getRuntime().exec("ping -w 2 -n 1 192.168.1.%i");
			// process1.destroy();
			Process process = Runtime.getRuntime().exec("arp -a");
			InputStreamReader inputStr = new InputStreamReader(
					process.getInputStream(), "GBK");
			BufferedReader br = new BufferedReader(inputStr);
			String temp = "";
			br.readLine();
			br.readLine();
			br.readLine();//       IP  ,       ,  。
			while ((temp = br.readLine()) != null) {
				System.out.println(temp);
				if (!ValueWidget.isNullOrEmpty(temp)) {
					StringTokenizer tokens = new StringTokenizer(temp);
					String x;
					InetAddress add=null;
					try {
						add = InetAddress.getByName(x = tokens
								.nextToken());
					} catch (java.net.UnknownHostException e) {
						continue;
					}
					// System.out.println(x);
					v.add(add);
					// System.out.println(add);
				}
			}
			System.out.println(SystemHWUtil.DIVIDING_LINE);
			v.add(InetAddress.getLocalHost());
			process.destroy();
			br.close();
			inputStr.close();
		} catch (Exception e) {
			System.out.println("        。");
			e.printStackTrace();
		}
		int cap = v.size();
		InetAddress[] addrs = new InetAddress[cap];
		for (int i = 0; i < cap; i++) {
			addrs[i] = (InetAddress) v.elementAt(i);
			 System.out.println(addrs[i]);
		}
		return addrs;

	}

	public static void main(String args[]) {
		InetAddress[] i = new LANIP().getAllOnline();
	}
}

 実行結果:
  169.254.255.255       ff-ff-ff-ff-ff-ff               
  224.0.0.2             01-00-5e-00-00-02               
  224.0.0.22            01-00-5e-00-00-16               
  224.0.0.252           01-00-5e-00-00-fc               
  226.81.9.8            01-00-5e-51-09-08               
  239.255.255.250       01-00-5e-7f-ff-fa               
  255.255.255.255       ff-ff-ff-ff-ff-ff               

  : 169.254.190.162 --- 0xd
  Internet                                
  169.254.255.255       ff-ff-ff-ff-ff-ff               
  224.0.0.2             01-00-5e-00-00-02               
  224.0.0.22            01-00-5e-00-00-16               
  224.0.0.252           01-00-5e-00-00-fc               
  226.81.9.8            01-00-5e-51-09-08               
  239.255.255.250       01-00-5e-7f-ff-fa               
  255.255.255.255       ff-ff-ff-ff-ff-ff               

  : 192.168.1.105 --- 0x14
  Internet                                
  192.168.1.1           00-21-5d-3c-79-16               
  192.168.1.106         b8-76-3f-a6-a8-e9               
  192.168.1.109         60-d8-19-14-6c-55               
  192.168.1.110         00-21-5d-3c-79-16               
  192.168.1.255         ff-ff-ff-ff-ff-ff               
  224.0.0.2             01-00-5e-00-00-02               
  224.0.0.22            01-00-5e-00-00-16               
  224.0.0.252           01-00-5e-00-00-fc               
  239.255.255.250       01-00-5e-7f-ff-fa               
  255.255.255.255       ff-ff-ff-ff-ff-ff               

  : 192.168.137.1 --- 0x15
  Internet                                
  192.168.137.182       84-7a-88-cf-87-35               
  192.168.137.255       ff-ff-ff-ff-ff-ff               
  224.0.0.2             01-00-5e-00-00-02               
  224.0.0.22            01-00-5e-00-00-16               
  224.0.0.252           01-00-5e-00-00-fc               
  239.255.255.250       01-00-5e-7f-ff-fa               
  255.255.255.255       ff-ff-ff-ff-ff-ff               
---------------------------------------
/169.254.255.255
/224.0.0.2
/224.0.0.22
/224.0.0.252
/226.81.9.8
/239.255.255.250
/255.255.255.255
/169.254.255.255
/224.0.0.2
/224.0.0.22
/224.0.0.252
/226.81.9.8
/239.255.255.250
/255.255.255.255
/192.168.1.1
/192.168.1.106
/192.168.1.109
/192.168.1.110
/192.168.1.255
/224.0.0.2
/224.0.0.22
/224.0.0.252
/239.255.255.250
/255.255.255.255
/192.168.137.182
/192.168.137.255
/224.0.0.2
/224.0.0.22
/224.0.0.252
/239.255.255.250
/255.255.255.255
wh-THINK/169.254.86.27