2013-12-09 75 views
0

我尝试了很多文件,从认证目录移动到服务器的目录,但我得到这个错误在线程异常线程“main” java.net.MalformedURLException:无协议:

异常“主“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 ) 在importador_documentos.Main.main(Main.java:82)

我尝试了很多东西,但没有已经解决了这个问题,请有人可以帮助我吗?

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... 
} 
+2

你连看预览为你写你的问题? http://stackoverflow.com/editing-help#code – SLaks

回答

2

变化:

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

到:

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

看到wikipedia file URI scheme

+0

很好,工作,现在我只有一个问题验证嘿嘿 – Deivi

相关问题