FTP服务器RETR命令仅下载小文件

时间:2015-11-02 11:48:31

标签: java ftp network-programming

出于某种原因,我的FTP服务器代码只允许我传输小文件。有谁知道我的代码可能出错? Part of Server Code Here

private void Retr(String filename) {

    OutputStream output = null;

    sendOut("150 Preparando-se para tranferir arquivo");

    try {

        output = this.dataSocket.getOutputStream();
        File file = new File(this.fileManager.getPath() + File.separator
                + filename);

        System.out.println(file.getAbsolutePath());
        RandomAccessFile reader = new RandomAccessFile(file, "rw");
        byte[] fileBytes = new byte[1024];
        System.out.println(file.getAbsolutePath());
        while (reader.getFilePointer() < reader.length())
            output.write(fileBytes, 0, reader.read(fileBytes));

        output.flush();
        output.close();

        sendOut("226 transferencia de " + filename + " concluída");

    } catch (IOException e) {

        e.printStackTrace();
    }
}

~~~~~日志文件失败之前~~~~~~

Status: Starting download of C:/Users/Public/desktop.ini
Command:    PWD
Response:   257 C:\Users
Command:    CWD C:/Users/Public/
Response:   200 cwd OK
Command:    PWD
Response:   257 C:\Users
Error:  Download failed

~~~~成功的日志文件~~~~~~~~~~

Status: Starting download of C:/Users/roy_fCreated/ntuser.ini
Command:    TYPE I
Response:   200 Successfully Set TypeType I
Command:    PASV
Response:   227 Entering passive mode (144,118,111,113,196,10)
Command:    RETR ntuser.ini
Response:   150 File status okay; about to open data connection
Response:   226 Closing data connection. Requested file action successful           ntuser.ini success!
Status: Download successful

0 个答案:

没有答案