久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Apache Commons FTP 問題

Apache Commons FTP problems(Apache Commons FTP 問題)
本文介紹了Apache Commons FTP 問題的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想用 Apache Commons Net 實現一個 FTP 客戶端,僅用于上傳數據.FTP 服務器的連接和登錄工作正常.但是上傳不正常.這些文件與原件相比有點大.并且文件已損壞.我嘗試了圖像、視頻和文本文件.只有文本文件沒問題.

I want to implement a FTP Client with Apache Commons Net only for uploading data. The Connection and Login to FTP-Server works fine. But the upload does not work right. The files are a little to big as the originals. And the files are damaged. I tried an image, a video and a textfile. Only the textfile is alright.

現在我在調試時看到了

boolean tmp=client.setFileTransferMode(FTPClient.BINARY_FILE_TYPE);

給我 false.所以不能設置.為什么?(也許這不是問題?)

gives me false. So it can not be set. Why? (Maybe this is not the problem?)

這是我的其余代碼

client=new FTPClient();

    try {           
        int reply;
        client.connect(url, port);
        reply = client.getReplyCode();

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


        client.login(user, pw);
        boolean xxx=client.setFileTransferMode(FTPClient.BINARY_FILE_TYPE);
        client.setControlKeepAliveTimeout(300);
        client.enterLocalPassiveMode();

if (client.isConnected())
    {
    try {
        File file=new File(<FILE>);
        FileInputStream inputStream = new FileInputStream(file);
        OutputStream outputStream = client.storeFileStream(file.getName());

          byte[] buffer = new byte[4096];
          int l;
       while((l = inputStream.read(buffer))!=-1)
               {
                outputStream.write(buffer, 0, l);
            }

          inputStream.close();
          outputStream.flush();
          outputStream.close();}

推薦答案

更改如下:

boolean xxx=client.setFileTransferMode(FTPClient.BINARY_FILE_TYPE);

應該是:

boolean xxx=client.setFileType(FTP.BINARY_FILE_TYPE);

您將 FileTransferModes 與 FileTypes 混淆了.

You have confused FileTransferModes with FileTypes.

可用的文件類型有:

  • FTP.ASCII_FILE_TYPE(默認)
  • FTP.BINARY_FILE_TYPE
  • FTP.EBCDIC_FILE_TYPE
  • FTP.LOCAL_FILE_TYPE

可用的 FileTransferMode 有:

The available FileTransferModes are:

  • FTP.STREAM_TRANSFER_MODE(默認)
  • FTP.BLOCK_TRANSFER_MODE
  • FTP.COMPRESSED_TRANSFER_MODE

我想如果 apache 為這些常量類型引入了枚舉,那么可以避免這種問題,但是該庫將無法用于 pre-java-5 運行時.
我想知道 java 1.4 兼容性到底有多大問題.

I suppose if apache introduced enums for these constant types, then this kind of problem could be avoided, but then the library would not be available to pre-java-5 runtimes.
I wonder how much of an issue java 1.4 compatibility really is.

這篇關于Apache Commons FTP 問題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 性高湖久久久久久久久3小时 | 性天堂网 | 欧美成年人网站 | 日韩视频一区二区三区 | 综合久久av | 九九热精品免费 | 亚洲精品视频在线观看免费 | yiren22综合网成人 | 国产精品国产 | 欧美激情一区二区三区 | 久久久影院 | 九色在线观看 | 久久精品视频9 | 不卡一区二区三区四区 | 91免费在线 | 一级毛片在线播放 | 久久久久久亚洲精品不卡 | 亚洲欧美日韩精品久久亚洲区 | 精品一区二区在线观看 | www.99re| 国产精品欧美一区二区 | 人成精品 | 99热热热| 在线婷婷| 亚洲一区二区三区四区在线观看 | 日韩精彩视频 | 日韩在线大片 | 亚洲欧美在线一区 | 凹凸日日摸日日碰夜夜 | 久久久蜜桃 | 日韩淫片免费看 | 凹凸日日摸日日碰夜夜 | 国产精品视频导航 | 亚洲一区二区三 | 天天射影院 | 久久国产精品久久久久 | 中文字幕一区二区三区精彩视频 | 一区影院 | 国产一区二区三区在线看 | 精品视频久久久 | 亚洲网一区 |