Javaµ÷ÓÃWMICÃüÁîµÄ·½·¨
½ñÌìҪд¸öÔ¶³ÌÖØÆô·þÎñµÄ¹¦ÄÜ£¬ÎªÁË¿ª·¢Ëٶȣ¬ÔÝʱ¶¨ÎªJava´úÂë+WMICÃüÁîµÄ·½·¨£¬¼òµ¥µÄ˵£¬¾ÍÊÇÀûÓÃJavaµ÷Óñ¾»úÓ¦ÓóÌÐòµÄ·½·¨¡£Éæ¼°µ½µÄJavaÀàÓÐjava.lang°üÀïÃæµÄRuntime¡¢Process¡¢ProcessBuilderÈý¸öÀ࣬ÒÔ¼°wmicÖÐÖØÆô·þÎñµÄÃüÁî¡£ÒòΪ֮ǰҲд¹ýÕâ·½ÃæµÄ¶«Î÷£¬ËùÒÔºÜÏ°¹ßÐÔµÄд³öÁË´úÂ룺
Process p = Runtime.getRuntime().exec("wmic ...");
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String tmp = null;
while ((tmp = br.readline()) != null) {
System.out.println(tmp);
}
int exitValue = p.waitfor();
ÔËÐУ¬½á¹û·¢ÏÖ³ÌÐò²»ÄÜÍ˳ö£¬Debug·¢ÏÖ³ÌÐò×èÈûÔÚbr.readline()ÖÐÁË£¬Ç¿ÖƽáÊø³ÌÐò£¬·¢ÏÖÖØÆô·þÎñµÄÃüÁîÕý³£ÏÂÏÂÈ¥ÁË£¬È¥µô³ÌÐòÖлñµÃ±ê×¼Êä³öµÄµØ·½ºÍ»ñµÃ·µ»Ø½á¹ûµÄµØ·½£¬ÃüÁîÒ²ÄÜÕý³£ÏÂÈ¥£¬¶øÇÒÕý³£Í˳ö¡£
Ϊʲô³ÌÐò»á×èÈûÄØ£¿GoogleÁËһϣ¬·¢ÏÖÁË´ó¼ÒµÄ½âÊÍ£¬Ó¦¸ÃÒ²ÊDZȽÏȨÍþµÄ½âÊÍ°É£ºÃ¿¸ö½ø³Ì¶¼ÓÐ×Ô¼ºµÄ±ê×¼ÊäÈë¡¢±ê×¼Êä³ö¡¢±ê×¼´íÎóÊä³ö£¬¶ÔÓÚijЩÒÀÀµÓÚOSµÄ½ø³Ì£¬¿ÉÄÜÆäÊä³ö»º³åÇøºÜС£¬Èç¹û²»Äܼ°Ê±µÄ¶Á³ö£¨±ê×¼Êä³ö¡¢±ê×¢´íÎóÊä³ö£©£¬½«µ¼Ö½ø³Ì²»ÄÜÕý³£Í˳ö¡£ÎҵijÌÐòÖбê×¼Êä³öÒѾ¶ÁÁË£¬ÏÔÈ»ÔÒò²»ÊÇÕâ¸ö£¬ÄѵÀÊÇ´íÎóÊä³ö»º³åÇøÖеÄÊý¾ÝûÓжÁ³öµ¼Öµģ¿´ø×ÅÕâ¸öÒÉÎÊ£¬¶Ô³ÌÐò×÷ÁËһЩ¸ü¸Ä£º
ProcessBuilder pb = new ProcessBuilder("wmic",...);
pb.redirectErrorStream(true);
Process p = pb.start();
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String tmp = null;
while ((tmp = br.readline()) != null) {
System.out.println(tmp);
}
int exitValue = p.waitfor();
±àÒëÔËÐУ¬·¢ÏÖ»¹ÊÇÓÐÎÊÌ⣬ÒÀÈ»»¹ÊÇ×èÈû¡£ÓÖgoogleÁËһϣ¬´ó¼ÒµÄÆÀÂÛ´ó¶à»¹ÊǹØÓÚ±ê×¼Êä³öºÍ±ê×¼´íÎóÊä³ö£¬ÄÇÕâ³ÌÐòÓ¦¸ÃÊÇûÓÐÎÊÌâÁË¡£ºóÀ´ÔÚcmdÖÐÇÃÈëwmicµÄÃüÁ·¢ÏÖwmicÃüÁîÇÃÈëÒÔºó»á½øÈëÒ»¸ö×ÔÓеÄÌáʾ·ûÖУ¬ÄѵÀÊÇÒòΪ±ê×¼ÊäÈëµÄÎÊÌâ¡£ºóÀ´ÓÖgoogleÁËһϣ¬ÑéÖ¤ÁËÎҵIJÂÏ룬¹ûÈ»ÊÇÒòΪwmic½ø³Ì»áµÈ´ý±ê×¼ÊäÈ룬¶ø³ÌÐòÖÐûÓд¦Àí±ê×¼ÊäÈëµÄµØ·½£¬ÊDZê×¼ÊäÈë×èÈûÁ˽ø³ÌµÄÍ˳ö£¬Ð޸ĴúÂ룺
ProcessBuilder pb = new ProcessBuilder("
Ïà¹ØÎĵµ£º
xmlÎļþÈçÏ ÅäÖù¦ÄÜ¿ª¹Ø
<Configurations>
<Samples>true</Samples>
<Excepts>true</Excepts>
<CheckFace>false</CheckFace>
<ThumbNail>false</ThumbNail>
&nbs ......
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet. ......
// µ¼Èë£É£Ï¿âÀà
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
// µ¼Èë¡¡£Ð£Ï£É¿âÀà
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi ......
Jsp
·½Ãæ
jspµÄ³£ÓõÄÃüÁî´ð£ºpage, include, talib, forward,
Servlet
·½Ãæ
1
¡¢ËµÒ»Ëµ
Servlet
µÄÉúÃüÖÜÆÚ
?
´ð:servletÓÐÁ¼ºÃ
µÄÉú´æÆڵĶ¨Ò壬°üÀ¨¼ÓÔغÍʵÀý»¯¡¢³õʼ»¯¡¢´¦ÀíÇëÇóÒÔ¼°·þÎñ½áÊø¡£Õâ¸öÉú´æÆÚÓÉjavax.servlet.Servlet½Ó¿ÚµÄ
init,serviceºÍdestroy·½·¨±í´ï¡£
2
¡¢
Servlet
°æ±¾¼ä
(
ÍüÁ ......
¡¡Javaƽ̨ÓÉJavaÐéÄâ»ú£¨Java Virtual Machine£©ºÍJava Ó¦Óñà³Ì½Ó¿Ú£¨Application Programming Interface¡¢¼ò³ÆAPI£©¹¹³É¡£Java Ó¦Óñà³Ì½Ó¿ÚΪJavaÓ¦ÓÃÌṩÁËÒ»¸ö¶ÀÁ¢ÓÚ²Ù×÷ϵͳµÄ±ê×¼½Ó¿Ú£¬¿É·ÖΪ»ù±¾²¿·ÖºÍÀ©Õ¹²¿·Ö¡£ÔÚÓ²¼þ»ò²Ù×÷ϵͳƽ̨ÉÏ°²×°Ò»¸öJavaƽ̨֮ºó£¬JavaÓ¦ÓóÌÐò¾Í¿ÉÔËÐС£ÏÖÔÚJavaƽ̨ÒѾǶÈëÁ˼¸ºõËù ......