易截截图软件、单文件、免安装、纯绿色、仅160KB

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的代理模式例子

(1).  创建一个接口, 要代理的类和 代理类都将继承它
package stone;
public interface Image {
    public void show();
}
(2). 创建要被代理的类:
package stone;
public class BigImage implements Image {
    public BigImage() {
        ......

Java两种异常模式

Java里有个很重要的特色是Exception ,也就是说允许程序产生例外状况。而在学Java 的时候,我们也只知道Exception 的写法,却未必真能了解不同种类的Exception 的区别。
首先,您应该知道的是Java 提供了两种Exception 的模式,一种是执行的时候所产生的Exception (Runtime Exception),另外一种则是受控制的Exception ......

Java加密和数字签名 1消息摘要

本文主要谈一下密码学中的加密和数字签名,以及其在java中如何进行使用。对密码学有兴趣的伙伴,推荐看Bruce Schneier的著作:Applied Crypotography.在jdk1.5的发行版本中安全性方面有了很大的改进,也提供了对RSA算法的直接支持,现在我们从实例入手解决问题(本文仅是作为简单介绍):
    一、密码学上 ......

JAVA常用操作语句 项目中的总结三


获得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 ......

JAVA常用操作语句 项目中的总结五


数字的格式化
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) 构造一 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号