简体   繁体   中英

Java: Accessing Windows files from Linux machine

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

On Windows, it works fine, using backslashes

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".

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

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?

(OS is Centos)

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

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

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

根据操作系统,使用java.io.File.separator检查是否存在反冲

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM