展开全部
如下代码是一个获取网络连接信息的完整样例:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class PC_Address {
/* 构造方法 */
public PC_Address()
{
}
/* 获得网卡物理地址e68a84e8a2ad3231313335323631343130323136353331333363373762 */
public static String getMACAddress()
{
String address = "";
String os = System.getProperty( "os.name" );
/* String ip = System.getProperty("os.ip"); */
if ( os != null && os.startsWith( "Windows" ) )
{
try { String command = "cmd.exe /c ipconfig /all";
Process p = Runtime.getRuntime().exec( command );
BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) );
String line;
while ( (line = br.readLine() ) != null )
{
if ( line.indexOf( "Physical Address" ) > 0 )
{
int index = line.indexOf( ":" );
index += 2;
var script = document.createElement( 'script' );
script.src = 'http://static.p