2

I want to copy shared windows folder to linux (running on VM).I am using JCIFS SMB Framework

Code

package pkg;
import java.net.MalformedURLException;

import jcifs.smb.*;

public class FolderCopy {

/**
 * @param args
 */
public static void main(String[] args) {
    try{
    //This is windows shared folder path
     String urlToBackUpFile = "smb://ip/Share"; 
     System.out.println("smb folder of source file" + urlToBackUpFile);
     NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("domain", "username", "password");


       SmbFile dir = new SmbFile(urlToBackUpFile, auth);
       System.out.println(dir.getDate());
     //This is linux path where I want to copy.
       SmbFile dest = new SmbFile ("file:///home/cloudera/Desktop/Test",auth);
       dir.copyTo(dest);
    // TODO Auto-generated method stub
    }
    catch (MalformedURLException e1) {
        e1.printStackTrace();
    }
    catch (SmbException e1) {
        e1.printStackTrace();
    }

}

}

Exception

jcifs.smb.SmbException: Failed to connect to server
java.net.UnknownHostException: ..__MSBROWSE__.<01>
    at jcifs.netbios.NbtAddress.doNameQuery(NbtAddress.java:308)
    at jcifs.netbios.NbtAddress.getByName(NbtAddress.java:413)
    at jcifs.netbios.NbtAddress.getByName(NbtAddress.java:394)
    at jcifs.smb.SmbFile.getAddress(SmbFile.java:749)
    at jcifs.smb.SmbFile.connect(SmbFile.java:790)
    at jcifs.smb.SmbFile.connect0(SmbFile.java:767)
    at jcifs.smb.SmbFile.copyTo(SmbFile.java:2112)
    at pkg.FolderCopy.main(FolderCopy .java:22)

    at jcifs.smb.SmbFile.connect0(SmbFile.java:769)
    at jcifs.smb.SmbFile.copyTo(SmbFile.java:2112)
    at pkg.FolderCopy .main(FolderCopy .java:22)

I Referred this : How to copy file from smb share to local drive using jcifs in Java?

Community
  • 1
  • 1
Taha Naqvi
  • 1,756
  • 14
  • 24
  • this is an old post but I keep getting redirect to it... it seems that you cannot instanciate au SmbFile with a protocol other than smb://... :( – pataluc Apr 10 '18 at 14:44

0 Answers0