发布于 2016-07-19 05:07:55 | 88 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的Java函数式编程,程序狗速度看过来!

Java程序设计语言

java 是一种可以撰写跨平台应用软件的面向对象的程序设计语言,是由Sun Microsystems公司于1995年5月推出的Java程序设计语言和Java平台(即JavaEE(j2ee), JavaME(j2me), JavaSE(j2se))的总称。


这篇文章主要介绍了Java获取mac地址的方法,涉及java针对系统硬件及IO操作的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了Java获取mac地址的方法。分享给大家供大家参考。具体如下:


/*
* GetMacAddress .java
*
* description:get Mac addreess
*
* @author hadeslee
*
* Created on 2007-9-27, 9:11:15
*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package test2; 
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
/**
*
*/
public class GetMacAddress {
public static String getMACAddress() {
String address = ""; 
String os = System.getProperty("os.name"); 
System.out.println(os); 
if (os != null && os.startsWith("Windows")) {
try {
ProcessBuilder pb = new ProcessBuilder("ipconfig", "/all"); 
Process p = pb.start(); 
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); 
String line; 
while ((line = br.readLine()) != null) {
if (line.indexOf("Physical Address") != -1) {
int index = line.indexOf(":"); 
address = line.substring(index+1); 
break; 
}
}
br.close(); 
return address.trim(); 
} catch (IOException e) {
}
}
return address; 
}
public static void main(String[] args) {
System.out.println("" + Test.getMACAddress()); 
}
}

希望本文所述对大家的java程序设计有所帮助。



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务