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

Apache Commons FTP 問題

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

問題描述

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

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.

現(xiàn)在我在調(diào)試時(shí)看到了

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

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

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);

應(yīng)該是:

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

您將 FileTransferModes 與 FileTypes 混淆了.

You have confused FileTransferModes with FileTypes.

可用的文件類型有:

  • FTP.ASCII_FILE_TYPE(默認(rèn))
  • FTP.BINARY_FILE_TYPE
  • FTP.EBCDIC_FILE_TYPE
  • FTP.LOCAL_FILE_TYPE

可用的 FileTransferMode 有:

The available FileTransferModes are:

  • FTP.STREAM_TRANSFER_MODE(默認(rèn))
  • FTP.BLOCK_TRANSFER_MODE
  • FTP.COMPRESSED_TRANSFER_MODE

我想如果 apache 為這些常量類型引入了枚舉,那么可以避免這種問題,但是該庫(kù)將無法用于 pre-java-5 運(yùn)行時(shí).
我想知道 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.

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

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

相關(guān)文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環(huán)繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動(dòng)生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數(shù)據(jù)庫(kù))
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對(duì)象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 欧美1级 | 日韩在线国产 | 国产精品一区二区三区久久 | 国产一区二区三区四区 | 久久www免费人成看片高清 | 美女黄视频网站 | 男人av在线播放 | 热99| 人人人人干 | 精品国产乱码久久久久久牛牛 | 91人人看| 超碰美女在线 | 一本岛道一二三不卡区 | 国产我和子的乱视频网站 | 欧美在线观看一区 | 亚洲精品一区二区三区免 | 欧美电影在线观看网站 | 久久机热 | 亚洲午夜在线 | 久草热8精品视频在线观看 午夜伦4480yy私人影院 | 天堂色 | 男女羞羞在线观看 | 韩国欧洲一级毛片 | 日韩色图视频 | 国产精品久久在线观看 | 欧美精品一区二区免费 | 亚洲成人一级 | 精品一二区 | 美女三区 | 日韩精品免费视频 | 亚洲国产成人av | 蜜臀网| 午夜天堂 | 九九热在线视频 | 美女中文字幕视频 | 国产中文视频 | 人人射人人 | 看片91| 亚洲欧美激情视频 | 四虎影院免费在线播放 | 中文字幕高清免费日韩视频在线 |