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

Java FTP上傳創(chuàng)建一個空文件

Java FTP upload creates an empty file(Java FTP上傳創(chuàng)建一個空文件)
本文介紹了Java FTP上傳創(chuàng)建一個空文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

當(dāng)我嘗試使用 Apache Commons FTPClient 上傳一個簡單的文本文件時:

When I try to upload a simple text file with the Apache Commons FTPClient and this code:

FTPClient ftp = new FTPClient();
int reply;

// connect
try {

    ftp.connect(serverAdd);
    ftp.login(username,password);
    reply = ftp.getReplyCode();

    if(FTPReply.isPositiveCompletion(reply)){
        System.out.println("Connected Success..");

        // upload file
        try {
            String fileDir = "testfile.txt";
            FileInputStream in = null;         
            in = new FileInputStream(fileDir);       
            ftp.storeFile(fileDir,in);
            System.out.println("File upload complete..");
        }catch(IOException e){
            System.out.println(e);
        }

        ftp.disconnect();
        System.out.println("Disconnected..");

    }else {
        System.out.println("Connection Failed..");
        ftp.disconnect();
    }    

} catch (SocketException ex) {
    ex.printStackTrace();
} catch (IOException ex) {
    ex.printStackTrace();
}

在 FTP 服務(wù)器的根目錄中創(chuàng)建了一個文件,但它是空的.怎么了?上傳 PDF 文件時,我已經(jīng)嘗試將 ftp 模式更改為 BINARY.但文件大小也是 0.

A file gets created in the root of the FTP server but it is empty. What's wrong? I already tried to change the ftp mode to BINARY when uploading a PDF file. But the file is also 0 in size.

ftp.setFileType(FTP.BINARY_FILE_TYPE);

我也只想上傳一堆txt文件,所以默認ascii模式應(yīng)該沒問題吧?

I also only want to upload a bunch of txt files, so the default ascii mode should be fine, right?

推薦答案

好吧,看來是我的防火墻問題了.當(dāng)我停用防火墻時,文件會毫無問題地寫入 ftp.

ok, it seems that it is a probem with my firewall. when I deactivate the firewall the file gets written to the ftp with no problem.

這篇關(guān)于Java FTP上傳創(chuàng)建一個空文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(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,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數(shù)據(jù)庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 国产精品久久二区 | 国产精品一区二区视频 | 久久av网站 | 久久久久久国模大尺度人体 | 精品欧美乱码久久久久久 | 亚洲欧美日韩国产综合 | 成人在线视频网址 | 欧美日韩久久 | 91精品国产高清久久久久久久久 | 香蕉91| 午夜av成人 | 国产一区二区麻豆 | 亚洲精品一区二区三区蜜桃久 | 黄色欧美大片 | 国产日韩免费视频 | 国产综合久久久久久鬼色 | 成人网av | 第四色影音先锋 | 羞羞视频在线观看网站 | 久久国产一区 | 欧美成人激情视频 | 99re视频精品 | 婷婷激情综合 | 免费观看一级黄色录像 | 国产在线资源 | 日韩一区二区三区在线 | 97精品一区二区 | 天天干天天色 | a级黄色片视频 | 97天天干| 久久成人国产 | 天天操网 | 97操操| 日韩精品免费在线观看 | 欧美日韩视频在线第一区 | 国产精品a免费一区久久电影 | 国产www在线 | 国产精品久久久av | 在线欧美视频 | 日日操夜夜操天天操 | 黄色一级大片在线免费看产 |