Java JCIFS how right to copy file from Samba to Windows local?
<p>I'm trying to create a Java application which can copy files from a Unix Samba share to a Windows folder. In order to achieve that, I'm using the  JCIFS library.</p>

<p>I have the following code:</p>

<pre><code>SmbFile smbFromFile = new SmbFile("smb:////192.168.10.1//data", auth);
smbFromFile.copyTo(destinationFolder);
</code></pre>

<p>I'm modifying it to:</p>

<pre><code>SmbFile smbFromFile = new SmbFile("smb:////192.168.10.1//data", auth);
SmbFile destinationFolder = new SmbFile("C:\\Temp\\IN\\");
smbFromFile.copyTo(destinationFolder);
</code></pre>

<p>But it gives me the following error:</p>

<pre><code>Exception in thread "main" jcifs.smb.SmbAuthException: Logon failure: unknown user name or bad password.
    at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:546)
    at jcifs.smb.SmbTransport.send(SmbTransport.java:663)
    at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:390)
    at jcifs.smb.SmbSession.send(SmbSession.java:218)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:176)
    at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
    at jcifs.smb.SmbFile.connect(SmbFile.java:957)
    at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
    at jcifs.smb.SmbFile.copyTo(SmbFile.java:2303)
    at RU.Tasks.Task3_Load_MedioSCP_Tekelek_file_To_DB_Oracle_BMCDB.main(Task3.java:203)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
</code></pre>

<p>If I try to create a new file on the Samba share, it works as expected:</p>

<pre><code>String user = "usersamba";
String pass ="1234";
String hostname = "192.168.10.1";
String sharedFolder = "data/new";
String path = "smb://"+hostname+"/"+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 !");
</code></pre>

<p>Please help to resolve this problem.</p>