繁体   English   中英

Java中基于TLS / SSL(FTPS-隐式)服务器的Java FTP-若干错误

[英]Java FTP over TLS/SSL (FTPS- Implicit) Server in Java - Several Error

我正在尝试将服务器与FTPSClient(真隐式)的端口990连接,似乎连接正常,但是它说找不到内部的PDF文件。

     String protocol = "TLS"; // TLS / SSL 
    boolean isImpicit = true; 
    int timeoutInMillis = 3000; 

    FTPSClient client = new FTPSClient(protocol, isImpicit); 

    client.setDataTimeout(timeoutInMillis); 
    client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); 

    try 
    { 
        int reply; 

        client.connect(server, port); 

        client.login(user, pass); 
        client.setFileType(FTP.BINARY_FILE_TYPE); 

        client.execPBSZ(0); 
        client.execPROT("P"); 

        System.out.println("Connected to " + server + "."); 

        reply = client.getReplyCode(); 

        if (!FTPReply.isPositiveCompletion(reply)) 
        { 
            client.disconnect(); 
            System.err.println("FTP server refused connection."); 
            System.exit(1); 
        } 

        client.listFiles(); 

        boolean retrieved = client.retrieveFile(Constantes.DIRECCION_FTP_PDF_FACTURAS + nombre_factura, new FileOutputStream(Constantes.DIRECCION_FTP_LOCAL_DESCARGAS + nombre_factura)); 

    } 
    catch (Exception e) 
    { 

        if (client.isConnected()) 
        { 
            try 
            { 
                client.disconnect(); 
            } 
            catch (IOException ex) 
            { 
                ex.printStackTrace(); 
            } 
        } 
        System.err.println("Could not connect to server."); 
        e.printStackTrace(); 
        return; 
    } 
    finally 
    { 
        System.out.println("# client disconnected"); 
        client.disconnect(); 
    } 

}

我遇到的错误是java.io.FileNotFoundException我尝试从C:\\开始编写完整路径,没有它,但是没有任何效果。

有人可以帮助我吗?

谢谢。

编辑:现在工作!

路径“ Program Files”包含一个空格,并且FileInputStream可能无法正确解析它。 可以尝试将您的文件夹放入“ C:/ Temp /”并再次进行测试。

FileNotFoundException到底在哪里发生?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM