Create file on another server
How would I create a file in ano开发者_高级运维ther windows server? The server has a username, and password, ip address and specific directory.
SAMBA! Braziiillll, Braziiiiiiillll!
Something like this:
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...
NOTE: The destination folder needs to be shared first!
As @orm already points out, this is answered already here FTP upload via sockets
Basically, you could reuse an existing library like Apache Commons Net to do it. For the specifics of using the FTP client have a look at the documentation for the class FTPClient class.
精彩评论