在另一台服务器上创建文件

时间:2011-09-19 21:30:53

标签: java windows ftp

如何在其他Windows服务器中创建文件?服务器有用户名,密码,IP地址和特定目录。

2 个答案:

答案 0 :(得分:1)

SAMBA! Braziiillll,Braziiiiiiillll!

这样的事情:

String userPass = "username:password";
String filePath = "smb://ip_address/shared_folder/file_name";

NtlmPasswordAuthentication authentication = new NtlmPasswordAuthentication(userPass);
SmbFile smbFile = new SmbFile(filePath, authentication);
SmbFileOutputStream smbFileOutputStream = new SmbFileOutputStream(smbFile);
PrintStream printStream = new PrintStream(smbFileOutputStream);
//You should be good from this point on...             

注意:首先需要共享目标文件夹!

答案 1 :(得分:0)

正如@orm已经指出的那样,这里已经回答FTP upload via sockets

基本上,您可以重复使用Apache Commons Net之类的现有库来执行此操作。有关使用FTP客户端的详细信息,请查看documentation for the class FTPClient class