| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
高端软件开发 = 年薪十万不是梦   
共有 325 人关注过本帖
标题:用java读MAC地址(原创)
收藏  订阅  推荐  打印
zengqingcong
Rank: 1
等级:新手上路
帖子:19
积分:196
注册:2007-10-23
用java读MAC地址(原创)

利用JAVA来读取本机MAC地址:代码如下

import java.io.*;
/*
* @Author Zengqingcong
* 2008-07-15
*/
public class ReadMacAddress {

    public String getPhysicAddress() {
        String physicalAddress = "";
        String line = "";
        try {
            Process process = Runtime.getRuntime().exec("cmd /c ipconfig /all");
            BufferedReader bufferedReader = new BufferedReader(
                    new InputStreamReader(process.getInputStream()));
            while ((line = bufferedReader.readLine()) != null) {
                if (line.indexOf("Physical Address. . . . . . . . . :") != -1) {
                    if (line.indexOf(":") != -1) {
                        physicalAddress = line.substring(line.indexOf(":") + 2);
                    }
                }

            }

        } catch (IOException e) {
            e.printStackTrace();
        }
        return physicalAddress;
    }

    public static void main(String[] args) {
        System.out.println("Your MacAddress is:\t"+new ReadMacAddress().getPhysicAddress());//My MacAddress is:00-16-E6-DA-AC-68
    }
}
2008-7-14 01:56
江西广东
Rank: 1
等级:新手上路
帖子:1
积分:110
注册:2008-8-15

你这个里面的. . . . . . . . .这么多个 点号是什么意思啊。可不可以解释一下啊
2008-8-16 10:14
msi110
Rank: 1
等级:新手上路
帖子:7
积分:174
注册:2008-4-15

嘿嘿····
投机取巧
2008-8-16 19:18
共有 324 人关注过本帖
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.047149 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved