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

將文件 FTP 到服務(wù)器,但結(jié)果以零字節(jié)大小到達

FTP a file to server, but it the result arrives with zero byte size(將文件 FTP 到服務(wù)器,但結(jié)果以零字節(jié)大小到達)
本文介紹了將文件 FTP 到服務(wù)器,但結(jié)果以零字節(jié)大小到達的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在嘗試使用 FTPClient 將文件上傳到數(shù)據(jù)庫服務(wù)器.顯示文件傳輸成功,但文件為空(大小為0字節(jié)).

I am tring to upload a file to a database server using FTPClient. It shows the file is transfered succesfully, but the file is empty (size 0 bytes).

以下是我用來構(gòu)建的源代碼.誰能解決這個問題?

Below is the source code that I have used to build. Can anyone resolve this issue?

package Examples;

import org.apache.commons.net.ftp.*;
import java.io.FileInputStream;
import java.io.IOException;

public class Main {

    public static void main(String[] args) {

        FTPClient client = new FTPClient();
        FileInputStream fis = null;

        try {

            client.connect("server");
            client.login("userid", "password");
            System.out.print("Message : " + client.getReplyString());

            client.changeWorkingDirectory("/loaddata");
            System.out.println("Working Directory" + client.printWorkingDirectory());

            client.setDefaultPort(22);
            int f1 = client.getDefaultPort();
            boolean f2 = client.setFileType(FTPClient.BINARY_FILE_TYPE);
            System.out.println("File transfer port no  " + f1);
            System.out.println("FTP server reply ." + client.getReplyString());

            String localfile = "c:/Touch.txt";
            fis = new FileInputStream(localfile);
            int lastSlash = localfile.lastIndexOf('/');
            String filename = localfile.substring(lastSlash+1);
            System.out.println("file : "+fis);

            client.setFileTransferMode(2);
            System.out.println("Flag reply ." + client.getReplyString());

            boolean flag = client.storeFile(filename,fis);

            System.out.println("Flag reply ." + client.getReplyString());

            if (flag) {
                System.out.println("Successfully uploaded the file");
            } else {
                System.out.println("Not able to upload the file");
            }

            fis.close();
            client.logout();
            System.out.println("Logout ." + client.getReplyString());

        } catch (Exception e) {
            System.out.println("Exception " + e);
        } finally {
            if (client.isConnected()) {
                try {
                    client.disconnect();
                    System.out.println("Server Disconnected." + client.getReplyString());
                } catch (IOException ioe) {
                    // do nothing
                }
            }
        }
    }
}

推薦答案

我刪除了client.changeWorkingDirectory("/loaddata");否則保持原樣并獲得成功.線路會不會有問題?比我再次使用 commons 3.1

I removed the client.changeWorkingDirectory("/loaddata"); otherwise left it all intact and got success. Could the line be a problem? Than again I used commons 3.1

這篇關(guān)于將文件 FTP 到服務(wù)器,但結(jié)果以零字節(jié)大小到達的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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(使用線程逐塊處理文件)
主站蜘蛛池模板: 欧美大片一区 | 成人在线精品视频 | 美日韩视频| 99精品欧美一区二区三区 | 久久精品亚洲一区二区三区浴池 | 91在线影院| 99精品一区二区三区 | 国产精品成人一区二区三区夜夜夜 | 国产精品av久久久久久久久久 | 精品一区二区三区在线观看 | 免费的av网站 | 精品久久久久香蕉网 | 国产午夜精品一区二区三区嫩草 | 手机av免费在线 | 午夜www | 国产日韩欧美综合 | 欧美精品中文字幕久久二区 | 中文字幕在线三区 | 亚洲精品无 | 精品国产欧美一区二区 | 国产高清一区二区三区 | 国产乱精品一区二区三区 | 精品亚洲一区二区三区 | 色天天综合 | 91av视频在线观看 | 日韩欧美亚洲 | 精品一区二区三区日本 | 日本天堂视频在线观看 | 国产一区二区三区在线 | 久久久高清| 国产精品毛片一区二区三区 | 五月婷婷视频 | 看片国产 | 91精品一区| av一区二区在线观看 | 欧美成人免费在线视频 | www.青娱乐| 国产精品视频在线播放 | 99热国产在线播放 | 观看av| 美日韩一区二区 |