Reputation: 306
I try to move a lot of files from a authenticated directory to a server directory, but am getting this error
Exception in thread "main" java.net.MalformedURLException: no protocol: /PGJ/portal/Importador_Documentos_Financeiro/FILES/FINANCEIRO/RF255677.pdf at java.net.URL.(Unknown Source) at jcifs.smb.SmbFile.(SmbFile.java:446) at importador_documentos.Main.main(Main.java:82)
I tried a lot of things, but nothing has solved this, please can someone help me?
public class Main {
public static String Pasta_Financeiro = System.getProperty("user.dir") +
File.separatorChar + "FILES" + File.separatorChar +
"FINANCEIRO" + File.separatorChar;
public static void main(String[] args) throws ClassNotFoundException,
SQLException,
FileNotFoundException,
IOException,
AuthenticationException
{
try{
jcifs.Config.registerSmbURLHandler();
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("cabanellos.local", "deivisson.sedrez", "password");
String path = "smb://fsct/scanpr$/";
SmbFile sFile = new SmbFile(path.toString(), auth);
SmbFile[] varTeste = sFile.listFiles();
SmbFile dir = new SmbFile(path.toString(), auth);
System.out.println(dir.getDate());
URL site;
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 ("//"+Pasta_Financeiro + varTeste[i].getName());
dir.copyTo(dest);
}
}
//rest of content...
}
Upvotes: 1
Views: 7207
Reputation: 11396
change:
SmbFile dest = new SmbFile ("//"+Pasta_Financeiro + varTeste[i].getName());
to:
SmbFile dest = new SmbFile ("file:///"+Pasta_Financeiro + varTeste[i].getName());
Upvotes: 2