久久久久久久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(使用線程逐塊處理文件)
主站蜘蛛池模板: 成人欧美一区二区三区视频xxx | 国产区第一页 | 亚洲视频免费在线 | 免费观看黄 | 精品日韩一区二区 | 日韩av三区 | 亚洲综合在线一区二区 | 亚洲网站免费看 | 超碰成人在线观看 | 欧美黄色片 | 欧美亚洲一级 | 国产.com | 色视频在线观看 | 国产国产精品久久久久 | 99视频入口| 一区二区小视频 | 粉嫩高清一区二区三区 | 欧美理论片在线 | 黄色一级在线播放 | 黄频视频 | 日韩一二区在线 | 免费av手机在线观看 | 精品久久久久久久久久 | 99精品视频网 | 99精品欧美一区二区三区 | 色婷婷国产精品综合在线观看 | 看av电影| 日韩在线一区二区三区 | 波多野结衣一区二区三区在线观看 | 99久久久久久久 | 最新国产视频 | 性色av网站 | 亚洲精品久久久久久久久久久久久 | 一级黄在线观看 | 操操操操操 | 欧美一级二级在线观看 | 91青娱乐在线 | 一级午夜aaa免费看三区 | 久久免费国产 | 国产精品一二区 | 新超碰97 |