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

為什么在 java 7 中 ftp 上傳速度很慢

why is ftp upload slow in java 7(為什么在 java 7 中 ftp 上傳速度很慢)
本文介紹了為什么在 java 7 中 ftp 上傳速度很慢的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想問是否有人知道有關 FTP 的任何 Java 7 問題?我使用了 Sun Net 和 Apache Commons Net 庫,并且在 Java 6 上都按預期執行.但是當我將開發環境 (Eclipse) 切換到 1.7 時,相同的操作執行速度非常慢(大約 4.5 到 8KB/s),這些是本地主機服務器和局域網內的另一臺服務器.

I wanted to ask if anyone knows about any Java 7 issues with FTP? I've used both the Sun Net and Apache Commons Net libraries and both perform as expected on Java 6. But when I switch my dev environment (Eclipse) to 1.7, the same operations perform really slow (about 4.5 to 8KB/s), and these are to localhost servers and another server within the LAN.

我嘗試過緩沖流、字節到字節傳輸、關閉 Nagle 算法,并使用 Apache 便捷方法 storeFile(),后者最終在 localhost 上執行加速,但再次減速到爬行遠程服務器.我還將所有機器都設置為關閉有狀態的 FTP 過濾.

I've tried buffered streams, byte-to-byte transfer, turning the Nagle Algorithm off, and using the Apache convenience method storeFile(), with the latter finally performing to speed on localhost but slowing down again to a crawl on a remote server. I also set all machines to turn off stateful FTP filtering.

    InputStream is = null;
    OutputStream os = null;
    try {
        is = new BufferedInputStream(prepareInputStream(data));
        os = new BufferedOutputStream(prepareOutputStream(data));
        if (is == null || os == null) {
            log.error("Can't build connection");
            return;
        }

        byte[] buf = new byte[4096];
        int c = 1;

        while (c > 0) {
            c = is.read(buf);
            if (c > 0)
            os.write(buf, 0, c);
            data.incrCurrentPosition();
            fireStateChanged(data);
        }
        data.incrCurrentPosition();
    } catch (IOException e) {
        log.error(e.getMessage(), e);
        setEnabled(false);  
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        if (os != null) {
            try {
                os.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

可以看出,這是非常標準的實現代碼.同樣,在 Java 6 中,事情進展得非常快.在 Java 7 中,Sun 和 Apache Commons 庫的速度都降低了 10 到 20 倍.使用像 FileZilla 這樣的 FTP 客戶端可以確認 FTP 運行正常,所以我認為它確實與 Java 7 有關.我盡我所能在網上搜索任何提到的問題,但大多數情況下,我看到的都是關于Java 7 和 Windows 7 防火墻沖突.

As can be seen, this is pretty standard implementation code. Again, in Java 6, things zip by really quick. In Java 7, it slows down by a factor of 10 to 20 for both the Sun and Apache Commons libraries. Using an FTP client like FileZilla confirms that FTP is functioning normally, so I think it really has something to do with Java 7. I dug as far as I could online for any mention of a problem but, mostly, the things I saw were about the Java 7 and Windows 7 firewall conflict.

提前感謝您提供的任何見解.

Thanks in advance for any insight given.

推薦答案

請檢查您當前的緩沖區大小:

Please check what your current buffer size is with :

ftpClient.getBufferSize();

如果您尚未將其設置為其他值,則該值將為零 (0).因此,將其設置為更高的值:

If you haven't already set it to something else, that will be zero (0). So, set it to a higher value :

ftpClient.setBufferSize(1048576);//1024*1024

你可以像以前一樣檢查它的當前值:

You can check its current value as before :

ftpClient.getBufferSize();

順便說一句,接受的答案 setBufferSize(0) 對我不起作用.我使用最新版本的 Apache commons,因此該解決方案可能適用于早期版本.如果將緩沖區大小設置為零,則當前版本不會發生任何變化.

By the way, the accepted answer, setBufferSize(0), did not work for me. I use the latest version of Apache commons, so probably that solution worked with earlier versions. If you set buffer size to zero, there will be no change with the current version.

這篇關于為什么在 java 7 中 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(使用線程逐塊處理文件)
主站蜘蛛池模板: 国产精品久久7777777 | 午夜爱爱毛片xxxx视频免费看 | 日本一区二区三区四区 | 日韩精品1区2区3区 成人黄页在线观看 | 精品日韩欧美一区二区 | 久久久久久久久久久国产 | 国产精品久久久久久中文字 | 国产精品久久久爽爽爽麻豆色哟哟 | 美女131mm久久爽爽免费 | 日批日韩在线观看 | 日韩精品免费视频 | 九七午夜剧场福利写真 | 在线观看亚洲 | 国产高清精品一区二区三区 | 中文字幕在线视频观看 | 国产a视频 | 日韩一区二区免费视频 | av一区二区三区 | 91精品国产色综合久久不卡98 | 婷婷综合激情 | 中文字幕日韩在线观看 | 亚洲视频免费观看 | 美美女高清毛片视频免费观看 | 婷婷桃色网 | 国产一区二区自拍 | 国产精品视频一区二区三区四蜜臂 | 嫩草影院网址 | 亚洲一区二区在线播放 | 欧美精品一区在线 | 国产高清在线精品 | 久久91 | 午夜视频网站 | 岛国精品 | 日本激情视频网 | 永久精品 | 亚洲视频精品在线 | 久久a久久| 国产成年人视频 | 国产精品18久久久久久白浆动漫 | 黄色大片在线播放 | 久久久91精品国产一区二区三区 |