java µ÷ÓÃwinrarÃüÁî
public static boolean winrar(String zipfile,String foler){ String rarPath="C:\\Program Files\\WinRAR\\WinRAR.exe"; String cmd=rarPath+" a "+zipfile+" "+foler;//rarPath ÎļþÃû£»foler ½«ÒªÑ¹ËõµÄÎļþÃû try{ Process proc=Runtime.getRuntime().exec(cmd); if(proc.waitFor() !=0){ if(proc.exitValue()==0) return true; } }catch(Exception e){ e.printStackTrace(); } return false; } ÔÚÒ³ÃæÖÐÓÐÒ»¸öÏÂÔØµÄ³¬Á´½Ó£¬µ±ÎÒµã»÷µÄʱºò£¬ËûÌáʾÈçÏÂÐÅÏ¢£ºd:\tomcat\bin\..Ŀ¼ÏÂÕÒ²»µ½Ä³¸öÎļþ ÄǸöÎļþÊÇÔÚ¹¤³ÌµÄÒ»¸öuploadÎļþ¼Ðϵģ¬Õâ¸ö·¾¶²»¶Ô£¬Ôõô²ÅÄÜÕÒµ½´ËÎļþ¶÷
ÄÄλ´óÏÀ°ï濴ϰ¡ Runtime.getRuntime().exec("cmd /c cd"); ÄãÔËÐÐÕâ¸öÃüÁîµÃµ½Ò»¸ö·¾¶¡£¡£¡£½âѹµÄÎļþÓ¦¸ÃÔÚÕâÀï »¹ÓÐÒ»µã¡£winϵ÷ÓÃcmdÃüÁî¡£²»ÒªÊ¹ÓÃwaitFor()·½·¨¡£ ³À´µÄ£ºYou need to drain the input stream to prevent because failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock. ²Î¿¼Ò»Ï£ºhttp://www.java-tips.org/java-se-tips/java.util/from-runtime.exec-to-processbuilder.htmlÒýÓà String cmd=rarPath+" a "+zipfile+" "+foler;//rarPath ÎļþÃû£»foler ½«ÒªÑ¹ËõµÄÎļþÃû ÕâÀïÄã¸Ä³É String cmd
Ïà¹ØÎÊ´ð£º
ÎÒÏë×ö¹»¹ºÎï³µÓÃsession µ«ÊDz»ÖªµÀÔõô»ñÈ¡¹ºÂòÊýÁ¿ ËÓоßÌåµÄ´úÂëÂð Ï£ÍûÄܸîÉá ÏÂÃæÊǹºÎï³µµÄºËÐÄ´úÂë ÓÐÁËÕâ¸ö ¾ÍÓ¦¸ÃÄܹ»×ö³öÀ´°É Java code: public void doPost(HttpServletRequest reque ......
²àÖØÓÚ»¥ÁªÍø¿ª·¢ JAVA¿ª·¢¹¤³Ìʦ ְλÃèÊö£º 1¡¢°´USECASE½øÐÐÒµÎñÐèÇó·ÖÎöºÍÈí¼þ¸ÅÒªÉè¼Æ£» 2¡¢½øÐÐÈí¼þÏêϸÉè¼ÆºÍ±àÂëʵÏÖ£¬È·±£ÐÔÄÜ¡¢ÖÊÁ¿ºÍ°²È«£» 3¡¢Î¬»¤ºÍÉý¼¶ÏÖÓÐÈí¼þ²úÆ·£¬¿ìËÙ¶¨Î»² ......
ÓÃRandomAccessFileдÈëTXTÎļþ²é¿´Ê±ÊÇÂÒÂ룬ÇëÎÊÓÐʲô·½·¨¿ÉÒÔд³É¿É¶ÁµÄÎļþ£¬²»ÊÇÓÃÆäËûµÄÎļþ²Ù×÷£¬¾ÍÊÇÖ»ÓÃRandomAccessFileµÄ·½·¨ÊÇ·ñ¿ÉÒÔʵÏÖ£¿ Java code: import java.io.*; public class RandomAcce ......