Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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


Ïà¹ØÎĵµ£º

Java»·¾³ÅäÖÆ

JAVA_HOME:
C:\Java\jdk1.6.0_17
Path:
%JAVA_HOME%\bin
ClassPath:
.;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar
ÎÒÃÇÐèÒªÉèÖÃÈý¸ö»·¾³±äÁ¿£ºJAVA_HOME¡¢PATH ºÍ CLASSPATH¡£
JAVA_HOME£º¸Ã»·¾³±äÁ¿µÄÖµ¾ÍÊÇ Java ËùÔÚµÄĿ¼£¬Ò»Ð© Java °æµÄÈí¼þºÍÒ»
Щ Java µÄ¹¤¾ßÐèÒªÓõ½¸Ã±äÁ¿£¬ÉèÖà PATH ºÍ CLASSP ......

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

JavaµÄContainerʾÀý³ÌÐò

package com.tiantian;
import java.util.*;
public class JAVAContainer {
public static void main(String[] args) throws Exception {
// ArrayList
{
ArrayList arraylist = new ArrayList();
arraylist.add(0, "end");//Ö¸¶¨Ë÷Òý¼ÓÈëÖµ
// Ðè×¢ÒâµÄÊÇ£¬Èç¹ûÏÖÓÐ2¸öÖµ£¬ÎÒÓÈëË÷Ò?µÄÄÇô¾Í»á³öÏÖÒì³£
f ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ