/**
* Tested to work with results from ARP command under Solaris, Linux, MS-Windows
* Note it does not always return a Mac address, even if the host exists. This represents more of
* a best 'effort' solution.
*/ private String getMacAddress ( String host ) throws UnknownHostException, IOException, InterruptedException
{
String macAddress = null;
InetAddress hostAddress = InetAddress.getByName( host );
StringBuilder stdOut = new StringBuilder();
Process proc = Runtime.getRuntime().exec( cmdArray ); new ProcessOutputHandler(stdOut,proc.getInputStream(),2001);
proc.waitFor();
String[] parts = stdOut.toString().split("\n"); for ( String part : parts )
{ if ( part.indexOf(ipAddress) > -1 )
{ return part;
}
} returnnull;
}
StringBuilder stdOut = new StringBuilder();
Process proc = Runtime.getRuntime().exec( cmdArray ); new ProcessOutputHandler(stdOut,proc.getInputStream(),2001);