简体   繁体   中英

Write a file to a Windows remote location from Unix

My application is deployed on a Unix machine and trying to write a file to remote Windows location. Instead of writing the file to the remote location, app is writing it to the Server's location ( Unix ) where the app is deployed to.

Any idea what could be going wrong? I have tried to put the location in the following ways:

1. FileOutputStream fs = new FileOutputStream(new File("\\\\windows_server_name\\anyDir\\filename.xml"))

2. FileOutputStream fs = new FileOutputStream(new File("\\windows_server_name\\anyDir\\filename.xml"))

It always creates the file at app server's location with the name of the remote location's address. eg

" \\\\windows_server_name\\anyDir\\filename.xml ". It creates a file like this.

To connect and write to your server you need a URL to connect to over ftp something like

URL url = new URL ("ftp://username:password@windows_server_name/anyDir/filename.xml");
URLConnection urlc = url.openConnection();
OutputStream os = urlc.getOutputStream();

...

I have resolved this issue. Actually the remote Windows location had to be mapped (mounted) to AIX server. And I had to just use the mapped location instead of directly accessing the remote Windows machine.

I did not make any code changes and was able to write the file in the same way as shown above in the question.

Thanks for your inputs all.

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