Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java »ñµÃMAC Address

import java.net.InetAddress;
import java.io.InputStream;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.text.ParseException;
import java.util.StringTokenizer;
public final class NetworkInfo {
private final static String getMacAddress() throws IOException {
String os = System.getProperty("os.name");
try {
if (os.startsWith("Windows")) {
return windowsParseMacAddress(windowsRunIpConfigCommand());
} else if (os.startsWith("Linux")) {
return linuxParseMacAddress(linuxRunIfConfigCommand());
} else {
throw new IOException("unknown operating system: " + os);
}
} catch (ParseException ex) {
ex.printStackTrace();
throw new IOException(ex.getMessage());
}
}
/*
* Linux stuff
*/
private final static String linuxParseMacAddress(String ipConfigResponse)
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(ipConfigResponse, "\n");
String lastMacAddress = null;
while (tokenizer.hasMoreTokens()) {
String line = tokenizer.nextToken().trim();
boolean containsLocalHost = line.indexOf(localHost) >= 0;
// see if line contains IP address
if (containsLocalHost && lastMacAddress != null) {
return lastMacAddress;
}
// see if line contains MAC address
int macAddressPosition = line.indexOf("HWaddr");
if (macAddressPosition <= 0)
continue;
String macAddressCandidate = line.substring(macAddressPosition + 6)
.trim();
if (linuxIsMacAddress(macAddressCandidate)) {
lastMacAddress = macAddressCandidate;
continue;
}
}
ParseException ex = new ParseException("cannot read MAC address for "
+ localHost + " from [" + ipConfigResponse + "]", 0);
ex.printStackTrace();
throw ex;
}
private final static boolean linuxIsMacAddress(String macAddressCandidate) {
// TODO: use a smart regular expre


Ïà¹ØÎĵµ£º

Java6 ½Å±¾ÒýÇæ(ÓÃJavaµ÷ÓÃJS½Å±¾)µ÷ÓÃjs

Java6 ½Å±¾ÒýÇæ(ÓÃJavaµ÷ÓÃJS½Å±¾)µ÷ÓÃjs
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import javax.script.Invocable;
 import javax.script.ScriptEngine;
 import javax.script.ScriptEngineManager;
 import javax.script.ScriptException;
 
&n ......

java³£ÓÃÀàµÄʹÓ÷½·¨

java³£ÓÃÀàµÄʹÓ÷½·¨
Interger£ºÕûÊýÀàÐÍ
£±¡¢ÊôÐÔ¡£
static int MAX_VALUE£º·µ»Ø×î´óµÄÕûÐÍÊý£»
static int MIN_VALUE£º·µ»Ø×îСµÄÕûÐÍÊý£»
static Class TYPE £º·µ»Øµ±Ç°ÀàÐÍ¡£
Àý×Ó£º
´úÂë:
System.out.println("Integer.MAX_VALUE: " + Integer.MAX_VALUE );
½á¹ûΪ£ºInteger.MAX_VALUE: 2147483647
&nb ......

Java¿ì½Ý¼üÖÆ×÷

Java¿ì½Ý¼üÖÆ×÷
ÓùýVBµÄÖªµÀ°´ÏÂF5ÊÇÔËÐд°Ì壬ÓùýPhotoshopµÄÖªµÀ°´ÏÂTabÊÇÒþ²ØËùÓÐÃæ°å
£¬ÄãµÄJava³ÌÐòÒ²ÏëÓÐÕâ¸ö¹¦ÄÜô£¿ÄÇôϣÍûÕâƪÎÄÕ¶ÔÄúÓÐËù°ïÖú¡£
×Ӳ˵¥ÀàJMenuItemÓÐÒ»¸ö·½·¨²»ÖªµÀÄã×¢Òâ¹ýûÓÐ:setAccelerator¡£
´ò¿ª°ïÖúÎļþ¶ÔÕâ¸ö·½·¨µÄÃèÊöÊÇ£º ÉèÖÃ×éºÏ¼ü£¬ËüÄÜÖ±½Óµ÷Óò˵¥ÏîµÄ²Ù×÷
ÕìÌýÆ÷¶ø²»±ØÏ ......

javaʵÏֵľ­µäµÝ¹éËã·¨ÈýÀý

javaʵÏֵľ­µäµÝ¹éËã·¨ÈýÀý
Ò»¡¢Ð´×÷´ËÎĵÄÔ­Òò£º
¡¡¡¡Ñ§¹ý³ÌÐòÉè¼ÆµÄÅóÓѶ¼ÖªµÀ£¬´æÔÚ×Ôµ÷ÓõÄËã·¨³Æ×÷µÝ¹éËã·¨¡£ µÝ¹éÍùÍùÄܸøÎÒÃÇ´øÀ´·Ç³£¼ò½à·Ç³£Ö±¹ÛµÄ´úÂëÐÎÊÆ£¬´Ó¶øʹÎÒÃǵıàÂë´ó´ó¼ò»¯£¬È»¶øµÝ¹éµÄ˼άȷʵºÜÎÒÃǵij£¹æ˼άÏàÄæµÄ£¬ÎÒÃÇͨ³£¶¼ÊÇ´ÓÉ϶øϵÄ˼άÎÊÌ⣬ ¶øµÝ¹éÇ÷ÊÆ´ÓÏÂÍùÉϵĽøÐÐ˼ά£¬ÕýÓÉÓÚ´Ë£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ