簡體   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