FTP 上传/下载文件大小为0、内容为空的解决办法

FTP包:org.apache.commons.net.ftp.FTPClient

The default settings for FTPClient are for it to use FTP.ASCII_FILE_TYPE , FTP.NON_PRINT_TEXT_FORMAT , FTP.STREAM_TRANSFER_MODE , and FTP.FILE_STRUCTURE . The only file types directly supported are FTP.ASCII_FILE_TYPE and FTP.BINARY_FILE_TYPE . Because there are at least 4 different EBCDIC encodings, we have opted not to provide direct support for EBCDIC. To transfer EBCDIC and other unsupported file types you must create your own filter InputStreams and OutputStreams and wrap them around the streams returned or required by the FTPClient methods. FTPClient uses the NetASCII filter streams to provide transparent handling of ASCII files. We will consider incorporating EBCDIC support if there is enough demand.
默认文件传输类型为ASCII_FILE_TYPE ,如果是普通文件上传下载就选BINARY_FILE_TYPE
ASCII_FILE_TYPE会更改文本内容,更改回车、空格以适应不同的操作系统,而BINARY_FILE_TYPE不会操作文本,所以推荐

ASCII_FILE_TYPE

public static final int ASCII_FILE_TYPE
A constant used to indicate the file(s) being transferred should be treated as ASCII. This is the default file type. All constants ending in FILE_TYPE are used to indicate file types.
See Also:
Constant Field Values

BINARY_FILE_TYPE

public static final int BINARY_FILE_TYPE
A constant used to indicate the file(s) being transferred should be treated as a binary image, i.e., no translations should be performed. All constants ending in FILE_TYPE are used to indicate file types.
See Also:
Constant Field Values

参考:FTPClient官方文档

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值