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());
}
}
相关文档:
jdk6和jdk5相比的新特性有:
1、instrumentation
在 Java SE 6 里面,instrumentation 包被赋予了更强大的功能:启动后的 instrument、本地代码 instrument,以及动态改变 classpath 等等。
2、Http有所增强
3、 Java 管理扩展(JMX) 架构及其框架,以及在 Java SE 5 中新引入的 JMX API -- java.l ......
var ProjectName = document.getElementById("").innerText;
ProjectName = ProjectName.replace(/(^\s*)|(\s*$)/g, ""); // 相当于Trim()函数 ......
eclipse选一个变量后,这个类里的该变量不变色问题解决:
alt + shift + o
/**
* 写入日志
* filePath 日志文件的路径
* code 要写入日志文件的内容
*/
public
static
boolean
print(String filePath,String code) {
try
{
File tofile
=
new
File(filePath);
......
由于有个合作项目,用到了REST,我们这边的服务器是java的,合作方那边主要是PHP环境,为了远程调用的问题,使用了REST作为API的实现方
案。现在项目做得差不多了,下面记下自己的一点心得,算是笔记吧。
REST(Representational State Transfer)的说法来自“Architectural Styles and the Desi ......
在项目中,我们很多都用到了xml文件,无论是参数配置还是与其它系统的数据交互。
今天就来讲一下Java 中使用dom4j来操作XML文件。
我们需要引入的包:
//文件包
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
//工具包
import java.util.Ite ......