java 系统自动获取ip地址和mac地址

如何使用java代码自动获取计算机的ip地址和mac地址
求java代码

 public static String getMacAddressIP(String remotePcIP) {
  String str = "";
  String macAddress = "";
  try {
   Process pp = Runtime.getRuntime().exec("nbtstat -A " + remotePcIP);
   InputStreamReader ir = new InputStreamReader(pp.getInputStream());
   LineNumberReader input = new LineNumberReader(ir);
   for (int i = 1; i < 100; i++) {
    str = input.readLine();
    if (str != null) {
     if (str.indexOf("MAC Address") > 1) {
      macAddress = str.substring(
        str.indexOf("MAC Address") + 14, str.length());
      break;
     }
    }
   }
  } catch (IOException ex) {
  }
  return macAddress;
 }

import java.net.*;public class NetInfo { public static void main(String[] args) { new NetInfo().say(); } public void say() { try { InetAddress i = InetAddress.getLocalHost(); System.out.println(i); //计算机名称和IP System.out.println(i.getHostName()); //名称 System.out.println(i.getHostAddress()); //只获得IP } catch(Exception e){e.printStackTrace();} }}