简体   繁体   English

从Unix将文件写入Windows远程位置

[英]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. 我的应用程序已部署在Unix计算机上,并试图将文件写入远程Windows位置。 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. app不会将文件写入远程位置,而是将其写入应用程序部署到的服务器位置( Unix )。

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 ". \\\\ 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以通过ftp进行连接,例如

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. 实际上,必须将远程Windows位置映射(安装)到AIX服务器。 And I had to just use the mapped location instead of directly accessing the remote Windows machine. 而且我只能使用映射的位置,而不是直接访问远程Windows计算机。

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. 感谢您的输入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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