gpt4 book ai didi

java - tomcat 7访问映射驱动器

转载 作者:行者123 更新时间:2023-11-28 23:46:25 25 4
gpt4 key购买 nike

我知道经常有人问类似的问题。但是解决方案对我不起作用。我确实尝试了 jcifs.jar(版本 1.3.17)。在这里,我发现它非常慢,并且出于某种原因有时会挂起。因为我已经足够绝望了,所以我可以应付极其缓慢的事情(并以不可靠的方式祈祷)。但现在我还有一个问题,我需要压缩网络驱动器上的一些内容。这不适用于 jcifs 或者我不知道如何。我的最佳解决方案是复制调用将执行复制的 .bat(这不起作用,因为它找不到驱动器)。并调用 7za.exe 对其进行压缩(不会找到驱动器)。示例代码:

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 身份验证,但我不知道在哪里以及如何设置。这对我有帮助吗?以及如何?

最佳答案

我找不到 jcifs 的替代品。结果不是最优的,但似乎还可以。我不认为这是 jcif more 网络的错,我对此没有影响。

关于java - tomcat 7访问映射驱动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13748314/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com