Access to file using Java with Samba JCIFS
You are making this harder than it should be. Please follow the below steps and make sure the shared folder you are creating has write access for this user you are using.
- download the jar file http://jcifs.samba.org/ (there is only one jar file)
- copy and paste the below code with your information for user name, password and shared folder and that's all you need
I was running this on Linux and wanted to write to a Windows box so you want to create a shared folder and put the shared folder name in the below variable if you don't know how to create shared folder on windows ...use google as always
String user = "your_user_name";
String pass ="your_pass_word";
String sharedFolder="shared";
String path="smb://ip_address/"+sharedFolder+"/test.txt";
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("",user, pass);
SmbFile smbFile = new SmbFile(path,auth);
SmbFileOutputStream smbfos = new SmbFileOutputStream(smbFile);
smbfos.write("testing....and writing to a file".getBytes());
System.out.println("completed ...nice !");