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
相关问答:
我的开发的平台是Myeclipes6.0 + tomcat5.x + mysql 我所有的编码方式都是用的UTF-8 我只用了Strtus框架 在一个form中如下用的是post的提交方式: <form class="form" action=&quo ......
<%@page language="java" contentType="text/html;charset=gb2312" import="java.sql.*"%> <jsp:useBean id="db" class="wang.connectDB"/> < ......
我们有项目想组建一个开发团队, 主要用 tomcat,java,struts2,我们的核心成员都是经验非常丰富的系统设计师, 如果您在天津,同时对java比较感兴趣, 可以加入我们。 希望要求 1。爱好编程 ......
import java.sql.Connection; import java.sql.Date; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class QueryTest&n ......