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里有个很重要的特色是Exception ,也就是说允许程序产生例外状况。而在学Java 的时候,我们也只知道Exception 的写法,却未必真能了解不同种类的Exception 的区别。
首先,您应该知道的是Java 提供了两种Exception 的模式,一种是执行的时候所产生的Exception (Runtime Exception),另外一种则是受控制的Exception ......
1.在你觉得有错的地方设置断点
2.点击甲壳虫一样的按钮下面的子按钮,也是甲壳虫一样的,叫Debug
3.运行程序,当程序运行到刚才设置断点的位置就会停下来,并且那行代码底色会高亮显示。
4.接着你在如下界面你可以看到你想要的信息
5.在Variables里面可以查看所有变量的值,比如刚才设置的断点里面的strClassName的值就 ......
一个软件设计的好坏,我想很大程度上取决于它的整体架构,而这个整体架构其实就是你对整个宏观商业业务的抽象框架,当代表业务逻辑的高层抽象层结构 合理时,你底层的具体实现需要考虑的就仅仅是一些算法和一些具体的业务实现了。当你需要再开发另一个相近的项目时,你以前的抽象层说不定还可以再次利用 呢,面对对象的设计 ......
数字的格式化
DecimalFormat df = new DecimalFormat(",###.00");
double aNumber = 33665448856.6568975;
String result = df.format(aNumber);
Sytem. out.println(result);
输出结果为:
33,665,448,856.66
分析字符串
StringTokenizer(String s) 构造一 ......