How would I create a file in another windows server? The server has a username, and password, ip address and specific directory.
Asked
Active
Viewed 835 times
0
-
1There is no need to add language name to the tittle, try always use tags for this. – Igor Milla Sep 19 '11 at 21:34
-
1This should do what you are asking for http://stackoverflow.com/questions/2705600/ftp-upload-via-sockets – Orn Kristjansson Sep 19 '11 at 21:34
-
1@igor: Unless you think the keyword is important enough that it should show in the related questions list, close as duplicate list, links, ... in fact tags are not a substitute for putting important information in the title. – Ben Voigt Sep 19 '11 at 21:36
-
@BenVoigt thanks for clarification, but I was trying to point OP only to not put language tag like `Java:` in the beginning of the title, as this is not usually welcome on SO. But your comment is completely correct. – Igor Milla Sep 19 '11 at 21:44
-
@Mike are you conversant with PHP? – Mob Sep 19 '11 at 22:26
2 Answers
1
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!

Marsellus Wallace
- 17,991
- 25
- 90
- 154
0
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.

Community
- 1
- 1

Rafael Cordones
- 831
- 1
- 7
- 8