首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

Tomcat执行winrar进行解压文件?解决思路

2011-12-29 
Tomcat执行winrar进行解压文件??????FileabcnewFile( D:\\sjhk\\zipDir )System.out.println(abc.getP

Tomcat执行winrar进行解压文件??????
File   abc   =   new   File( "D:\\sjhk\\zipDir ");
System.out.println(abc.getPath());
String   SourcePath= "c:\\ ";
                          String   toPath= "D:\\ ";
        String   Filename= "abc123 ";
        String   rarPath= "WinRAR.exe ";
        String   cmd=rarPath+ "   x   -ibck   -y   "   +   SourcePath   + "\\ "+     Filename   +   "   "+toPath;
        Runtime.getRuntime().exec(cmd);
                Process   proc;
                proc   =   Runtime.getRuntime().exec(cmd);
               
                    if   (proc.waitFor()   !=   0)   {
                        System.err.println( "exit   value   =   "   +
                                                              proc.exitValue());
                    }  
上段代码使用java调用可以正确执行,但是写到tomcat中就不行了,程序异常终止,是不是tomcat有什么安全限制,不能执行外部程序啊,怎么能让tomcat执行。

[解决办法]
看看TOMCAT的LOG文件输出什么错误信息??
[解决办法]
rar的命令行模式应该是rar.exe

热点排行