- 浏览: 528556 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (339)
- JavaBase (27)
- J2EE (70)
- Database (22)
- Spring (3)
- struts1.x (6)
- struts2.x (16)
- Hibernate (10)
- IBatis (4)
- DWR (1)
- SSH (5)
- Oracle (31)
- HTML (12)
- javascript (11)
- Thinking (3)
- Workflow (5)
- Live (13)
- Linux (23)
- ExtJS (35)
- flex (10)
- php (3)
- Ant (10)
- ps (1)
- work (2)
- Test (1)
- Regular Expressions (2)
- HTTPServer (2)
- 方言 (1)
- 生活 (2)
- Sybase PowerDesigner (0)
最新评论
-
mikey_5:
非常感谢楼主的分享,<parameter propert ...
Check the output parameters (register output parameters failed) IN Ibatis -
影子_890314:
我现在也有这个错误,求解!
Check the output parameters (register output parameters failed) IN Ibatis -
358135071:
学习了,感谢分享!
使用hibernate 代替 mysql 中 limit 進行分頁 -
wjpiao:
你下面的“正确的映射”里面不是还是有number类型吗?
Check the output parameters (register output parameters failed) IN Ibatis -
zh_s_z:
很有用!弄一份吧!
Oracle数据库分区表操作方法
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.NetworkInterface;
import java.util.Enumeration;
public class MACUtil {
// 返回一个字节的十六进制字符串
public static String hexByte(byte b) {
String s = "000000" + Integer.toHexString(b);
return s.substring(s.length() - 2);
}
/**
* JDK1.6新特性获取网卡MAC地址
*/
public static void getMac() {
try {
Enumeration<NetworkInterface> el = NetworkInterface
.getNetworkInterfaces();
while (el.hasMoreElements()) {
byte[] mac = el.nextElement().getHardwareAddress();
if (mac == null) {
continue;
}
StringBuilder builder = new StringBuilder();
for (byte b : mac) {
builder.append(hexByte(b));
builder.append("-");
}
builder.deleteCharAt(builder.length() - 1);
System.out.println(builder);
}
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* 原始的获取网卡MAC地址
*/
public static void getMacOnWindow() {
try {
String mac = null;
Process process = Runtime.getRuntime().exec("ipconfig /all");
BufferedReader buffer = new BufferedReader(new InputStreamReader(
process.getInputStream()));
for (String line = buffer.readLine(); line != null; line = buffer
.readLine()) {
System.out.println(line);
int index = line.indexOf("Physical Address");
if (index <= 0) {
continue;
}
mac = line.substring(index + 36);
break;
}
buffer.close();
process.waitFor();
System.out.println(mac);
} catch (Exception exception) {
exception.printStackTrace();
}
}
public static void main(String[] args) throws Exception {
System.out.println("通过调用DOS命令获得本机器的所有的网卡MAC如下:");
getMacOnWindow();
System.out.println("通过JDK获得本机器的所有的网卡MAC如下:");
getMac();
}
}
//------------------------------------------------------------------------------------------------------------------------------
package com.jtosa.util;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.text.ParseException;
import java.util.StringTokenizer;
import java.io.BufferedInputStream;
public class MACUtil {
private final static int MACADDR_LENGTH = 17;
private final static String WIN_OSNAME = "Windows";
private final static String WIN_MACADDR_REG_EXP = "^[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}$";
private final static String WIN_MACADDR_EXEC = "ipconfig /all";
public final static String getMacAddress() throws IOException {
String os = System.getProperty("os.name");
try {
if (os.startsWith(WIN_OSNAME)) {
return winMacAddress(winIpConfigCommand());
}
// 下面是其它的操作系统的代码,省略了!
// LINUX --> else if (os.startsWith("Linux")) {
//
// Process p = Runtime.getRuntime().exec("ifconfig");
// MAC OSX --> else if(os.startsWith("Mac OS X")) {
//
// Process p = Runtime.getRuntime().exec("ifconfig");
else {
throw new IOException("OS not supported : " + os);
}
} catch (ParseException e) {
e.printStackTrace();
throw new IOException(e.getMessage());
}
}
private final static String winMacAddress(String ipConfigOutput)
throws ParseException {
String localHost = null;
try {
localHost = InetAddress.getLocalHost().getHostAddress();
} catch (java.net.UnknownHostException ex) {
ex.printStackTrace();
throw new ParseException(ex.getMessage(), 0);
}
StringTokenizer tokenizer = new StringTokenizer(ipConfigOutput, "\n");
String lastMacAddress = null;
while (tokenizer.hasMoreTokens()) {
String line = tokenizer.nextToken().trim();
// see if line contains IP address
if (line.endsWith(localHost) && lastMacAddress != null) {
return lastMacAddress;
}
// see if line contains MAC address
int macAddressPosition = line.indexOf(":");
if (macAddressPosition <= 0)
continue;
String macAddressCandidate = line.substring(macAddressPosition + 1)
.trim();
if (winIsMacAddress(macAddressCandidate)) {
lastMacAddress = macAddressCandidate;
continue;
}
}
ParseException ex = new ParseException("cannot read MAC address from ["
+ ipConfigOutput + "]", 0);
ex.printStackTrace();
throw ex;
}
private final static boolean winIsMacAddress(String macAddressCandidate) {
if (macAddressCandidate.length() != MACADDR_LENGTH)
return false;
if (!macAddressCandidate.matches(WIN_MACADDR_REG_EXP))
return false;
return true;
}
private final static String winIpConfigCommand() throws IOException {
Process p = Runtime.getRuntime().exec(WIN_MACADDR_EXEC);
InputStream stdoutStream = new BufferedInputStream(p.getInputStream());
StringBuffer buffer = new StringBuffer();
for (;;) {
int c = stdoutStream.read();
if (c == -1)
break;
buffer.append((char) c);
}
String outputText = buffer.toString();
stdoutStream.close();
return outputText;
}
public final static void main(String[] args) {
try {
System.out.println("MAC ADDRESS");
System.out.println(" OS : "
+ System.getProperty("os.name"));
System.out.println(" IP/Localhost: "
+ InetAddress.getLocalHost().getHostAddress());
System.out.println(" MAC Address : " + getMacAddress());
} catch (Throwable t) {
t.printStackTrace();
}
}
}
发表评论
-
Moto官方GMS谷歌服务套件For XT800+下载和使用教程
2011-05-21 22:03 3905MOTOXT800+ ANDROID ROM address: ... -
barcode4j
2011-05-14 17:34 932project net address: htt ... -
org.logicalcobwebs.proxool 连接池异常
2011-05-09 10:02 75532011/05/09 09:59:44:695 ERROR [ ... -
Spring JDBC 调用 procedure
2011-03-25 16:12 1300import java.sql.CallableStateme ... -
JDBC Call MySQL Proc
2011-03-25 15:10 972MySQL PROC : ------------- ... -
Axis 开发WebService
2011-03-14 16:11 847net address : http://blog.cs ... -
java 内存查看软件_Jprofiler
2011-03-04 14:34 854java 内存查看软件(Eclipse plugin): ... -
了解 Eclipse 插件如何使用 OSGi
2011-02-18 09:39 943http://www.ibm.com/developerwor ... -
tomcat out of Memory error
2011-01-28 17:03 979net address: http://www.iteye.c ... -
bak_
2010-12-30 17:48 769weblog address: http://kenwubl ... -
jsp tag page plugin
2010-12-09 15:31 853jsp tag page plugin: http://ww ... -
page cache set
2010-12-02 17:03 807response.setHeader("Ca ... -
properties file editor
2010-11-28 14:26 839net address(多种语言在同一个表格中,容易排除遗漏属 ... -
判断浏览器的语言
2010-11-26 17:43 816*.jsp page : <% Lan ... -
属性文件编辑器
2010-11-26 14:43 907在此想和大家分享一个不错的编写properties文件的Ecl ... -
google-api-translate-java
2010-11-14 17:51 767// http://code.google.com/p/go ... -
regex in java
2010-11-14 16:06 860Pattern类: 例子: Pat ... -
EHCache 配置详解
2010-10-13 17:22 10511EHCache 是一个纯java 的在进程中的缓存 ... -
displaytag jsp paging tag
2010-10-13 10:04 829displaytag :jsp paging tag ... -
Spring_Recipes code
2010-09-29 23:47 673code source: http://www.apress ...
相关推荐
vc获得网卡MAC地址 Get MAC Address, SNMP Method
Visual c++编程源代码 Winpcap 编程实例 读取分析网卡物理地址
每台计算机都有为一个MAC地址(物理地址/硬件地址)固化在适配器的ROM中。通过编程的方法获取本机的MAC地址(6字节大小)。
get Mac address of your computer
get mac address vi for windows
Get Mac address by c#
const MacAddress = require ( 'get-mac-address' ) ; MacAddress ; /* { lo0: '00:00:00:00:00:00', en0: 'a4:5e:60:eb:cc:48', wdl0:'c2:da:24:52:4f:f6' } */ 命令行界面 $ npm install --global get-mac-...
在VC6.0下编译通过,能够获取本地机器上的所有的IPV6 address 非常的完整的获取
Get_Port_Address to get LPT address port
java NetworkInterface类获取MAC地址。
use mac_address :: get_mac_address; fn main () { match get_mac_address () { Ok ( Some (ma)) => { println! ( "MAC addr = {}" , ma); println! ( "bytes = {:?}" , ma. bytes ()); } Ok ( None ) => ...
获取线程的起始地址的样例,VS2008可以直接编译通过。
本vi是通过执行系统指令来获取MAC地址
从堆内存中解析堆中所有handler大小,并用16进制数据记录
两种获取MAC地址的方法,一种是可以获得本机的MAC地址,另一个是通过ip地址获取远程客户端的MAC地址。
利用getdata获取图形数据
NULL 博文链接:https://beinuo0501.iteye.com/blog/776690
example of get IP address in android
"getaddrinfo", a function that provides protocol-independent translation from an ANSI host name to an IP address written in C
//get the MAC address ManagementClass mc=new ManagementClass("Win32_NetworkAdapterConfiguration"); ManagementObjectCollection moc=mc.GetInstances(); string[] MacAddress=new string[2]; int ii=0; ...