Java:从Linux机器访问Windows文件

时间:2021-04-13 15:53:32

I've got a Java program that saves a new PDF file to a shared network location.

我有一个Java程序,可以将新的PDF文件保存到共享的网络位置。

On Windows, it works fine, using backslashes

在Windows上,它使用反斜杠工作正常

serverDirName=\\\\10.20.1.1\\c$\\input

To try skip all the complexity of permissions, I've set the sharing on that folder in Windows to Read/Write for "Everyone".

为了尝试跳过所有权限的复杂性,我将Windows中该文件夹的共享设置为“Everyone”的读/写。

I'd like to try run the program from a linux server.
Straight off the bat, I get:

我想尝试从Linux服务器运行程序。直接蝙蝠,我得到:

Error: java.io.FileNotFoundException: \\10.20.1.1\e$\input/8106070121089/Doctor-Diagnosis-201003291.pdf (No such file or directory)

So I tried switching to:

所以我尝试切换到:

serverDirName=//10.20.1.1/e$/input

and got:

Error: java.io.IOException: Directory '/10.20.1.1/e$/input/8103205007085' could not be created

I presume there's some basic network requirements that I'm lacking, in order to communicate with a Windows machine, but any idea what that is?

我认为有一些我缺乏的基本网络要求,以便与Windows机器进行通信,但不知道那是什么?

(OS is Centos)

(操作系统是Centos)

2 个解决方案

#1


2  

To access windows directory you should mount windows shared directory to your linux server.

要访问Windows目录,您应该将Windows共享目录挂载到您的Linux服务器。

See https://wiki.centos.org/TipsAndTricks/WindowsShares

After this you'll be able to use this windows directory as a local linux directory.

在此之后,您将能够将此Windows目录用作本地linux目录。

#2


0  

Check with java.io.File.separator for backlash according to OS.

根据操作系统检查java.io.File.separator的反冲。

#1


2  

To access windows directory you should mount windows shared directory to your linux server.

要访问Windows目录,您应该将Windows共享目录挂载到您的Linux服务器。

See https://wiki.centos.org/TipsAndTricks/WindowsShares

After this you'll be able to use this windows directory as a local linux directory.

在此之后,您将能够将此Windows目录用作本地linux目录。

#2


0  

Check with java.io.File.separator for backlash according to OS.

根据操作系统检查java.io.File.separator的反冲。