2012-12-06 93 views
0

我知道经常会问到类似的问题。但是这些解决方案并不适合我。我曾尝试jcifs.jar(版本1.3.17)。在这里,我发现它极其缓慢,并且由于某种原因,有时会简单地挂起。由于我非常渴望,所以我可以应付极其缓慢(并且不可靠的祈祷)。但是现在我也遇到了需要压缩网络驱动器上的一些内容的问题。这不适用于jcifs或我不知道如何。我的最佳解决方案是复制调用.bat将执行副本(由于无法找到驱动器,因此无法正常工作)。并调用7za.exe来压缩它(不会找到驱动器)。 示例代码:tomcat 7访问映射驱动器

public static int SevenZip(String source, String dest, ServletContext context) throws IOException, InterruptedException 
{ 
    String zipFile = "\"" + context.getRealPath("") + "\\WEB-INF\\7za.exe\""; 

    String zipInstruction = zipFile + " a " + dest + " " + source; 
    Logger.getAnonymousLogger().info(zipInstruction); 

    Process process = Runtime.getRuntime().exec(zipInstruction); 
    StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "ERR"); 
    StreamGobbler outputGobbler = new StreamGobbler(process.getInputStream(), "OUT"); 
    errorGobbler.start(); 
    outputGobbler.start(); 

    return process.waitFor(); 
} 

如果不是作为一个servlet完成的代码将工作。 忽略StreamGobbler它只是从进程中获取错误和输出流。 我在某个地方看到可以将tomcat设置为windows身份验证,但我不明白在哪里以及如何。这会帮助我吗?如何?

+0

你应该通过serverfault里面的批处理文件询问windows身份验证。 – poussma

+0

我在serverfault上找不到任何相关的东西。 – Martin

回答

0

我找不到jcifs的替代品。结果并不理想,但似乎没有问题。我不认为这是jcif网络的错误,我对此没有任何影响。