当前位置: 动力学知识库 > 问答 > 编程问答 >

java - error connect in smb dir using jcifs

问题描述:

If i try

NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("cabanellos.local","deivisson.sedrez", "passs");

String path = "smb://fsct/scanpr$/test.txt";`

SmbFile sFile2 = new SmbFile(path, auth); `

It connects and creates a file, but if i try:

NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("cabanellos.local", "deivisson.sedrez", "passs");

String path = "smb://fsct/scanpr$/";

SmbFile sFile2 = new SmbFile(path, auth);

SmbFile[] varTeste = dir.listFiles();

for(int i=0;i<varTeste.length;i++){

if(varTeste[i].isFile()){

//site = new URL((Pasta_Financeiro + varTeste[i].getName()).toString());

SmbFile dest = new SmbFile ("file:///"+Pasta_Financeiro + varTeste[i].getName());

dir.copyTo(dest);

}

}

I get this exception "Logon failure: unknown user name or bad password." but all is correctly

Why this is happening?

网友答案:

You probably should use "smb://"+Pasta_Financeiro instead of "file:///"+Pasta_Financeiro

网友答案:

i use

SmbFile remoteFile = new SmbFile("smb://...") OutputStream os = new FileOutputStream("/path/to/local/file"); InputStream is = remoteFile.getInputStream(); int bufferSize = 1024; byte[] b = new byte[bufferSize]; int noOfBytes = 0; while( (noOfBytes = is.read(b)) != -1 ) { os.write(b, 0, noOfBytes); } os.close(); is.close();

also

dir.copyTo(dest);

and its works

ty for help

分享给朋友:
您可能感兴趣的文章:
随机阅读: