Reputation: 2339
How would I create a file in another windows server? The server has a username, and password, ip address and specific directory.
Upvotes: 0
Views: 1047
Reputation: 18601
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!
Upvotes: 1
Reputation: 831
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.
Upvotes: 0