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

將文件 FTP 到服務器,但結果以零字節大小到達

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

問題描述

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

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

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

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

這篇關于將文件 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(使用線程逐塊處理文件)
主站蜘蛛池模板: 国产精品久久久久久婷婷天堂 | 中文字幕高清 | 欧美高清免费 | 久久精品国产一区二区 | 久久精品在线 | 国产精品观看 | 亚洲欧洲精品在线 | 欧美在线观看免费观看视频 | 天天色综网 | 久久久国产一区二区三区四区小说 | 一区二区三区精品在线 | 九色网址| 精品国产一级片 | 亚洲成人自拍 | 久久中文字幕视频 | 二区av| 999久久久国产精品 欧美成人h版在线观看 | 亚洲精品99 | 一级在线视频 | 2022国产精品| 99久久中文字幕三级久久日本 | 色伊人| 九九久久国产 | 久久久久久亚洲精品不卡 | 国产a区| 国产探花在线精品一区二区 | 久久宗合色 | 国产免费一区二区三区 | 亚州视频在线 | 91久久久久| 免费一级毛片 | 欧美午夜视频 | 午夜播放器在线观看 | 一区二区三区精品视频 | 国产精品一区二区三区在线 | 高清亚洲 | 毛片国产 | 97精品视频在线观看 | 久视频在线观看 | 中文字幕在线观看www | 国产精品一区二区视频 |