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());
}
}
相关文档:
(1). 创建一个接口, 要代理的类和 代理类都将继承它
package stone;
public interface Image {
public void show();
}
(2). 创建要被代理的类:
package stone;
public class BigImage implements Image {
public BigImage() {
......
jdk6和jdk5相比的新特性有:
1、instrumentation
在 Java SE 6 里面,instrumentation 包被赋予了更强大的功能:启动后的 instrument、本地代码 instrument,以及动态改变 classpath 等等。
2、Http有所增强
3、 Java 管理扩展(JMX) 架构及其框架,以及在 Java SE 5 中新引入的 JMX API -- java.l ......
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* @author troy(J2EE)
* @version 1.0
*/
public class Test {
public static void main(String[] args) throws Exception {
DateFormat df = DateFormat.getDateInstance();
&n ......
1.字符
x 字符 x。例如a表示字符a
\\ 反斜线字符。在书写时要写为\\\\。(注意:因为java在第一次解析时,把\\\\解析成正则表达式\\,在第二次解析时再解析为\,所以凡是不是1.1列举到的转义字符,包括1.1的\\,而又带有\的都要写两次)
\0n 带有八进制值 0的字符 ......
获得mysql和oracle链接的类
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectDB {
private static final String MYSQL = "jdbc:mysql://";
private static final String ORACLE = "jdbc:oracle:thin:@";
private ConnectD ......