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身份驗證,但我不明白在哪裏以及如何。這會幫助我嗎?如何?
你應該通過serverfault裏面的批處理文件詢問windows身份驗證。 – poussma
我在serverfault上找不到任何相關的東西。 – Martin