java ftp windows linux 不可以,Apache FTPClient - 在Linux上不完整的文件检索,适用于Windows...

我在Websphere上有一个Java应用程序,它使用Apache Commons FTPClient通过FTP从Windows服务器检索文件。当我将应用程序部署到在Windows环境中运行的Websphere时,我能够干净地检索所有文件。但是,当我在Linux上将相同的应用程序部署到Webpshere时,有时我会收到不完整或损坏的文件。但是这些情况是一致的,因此每次相同的文件都会失败并返回相同数量的字节(通常只比我应该得到的字节少几个字节)。我会说我可以在Linux上成功读取大约95%的文件。

这是相关代码......

ftpc = new FTPClient();

// set the timeout to 30 seconds

ftpc.enterLocalPassiveMode();

ftpc.setDefaultTimeout(30000);

ftpc.setDataTimeout(30000);

try

{

String ftpServer = CoreApplication.getProperty("ftp.server");

String ftpUserID = CoreApplication.getProperty("ftp.userid");

String ftpPassword = CoreApplication.getProperty("ftp.password");

log.debug("attempting to connect to ftp server = "+ftpServer);

log.debug("credentials = "+ftpUserID+"/"+ftpPassword);

ftpc.connect(ftpServer);

boolean login = ftpc.login(ftpUserID, ftpPassword);

if (login)

{

log.debug("Login success..."); }

else

{

log.error("Login failed - connecting to FTP server = "+ftpServer+", with credentials "+ftpUserID+"/"+ftpPassword);

throw new Exception("Login failed - connecting to FTP server = "+ftpServer+", with credentials "+ftpUserID+"/"+ftpPassword);

}

is = ftpc.retrieveFileStream(fileName);

ByteArrayOutputStream out = null;

try {

out = new ByteArrayOutputStream();

IOUtils.copy(is, out);

} finally {

IOUtils.closeQuietly(is);

IOUtils.closeQuietly(out);

}

byte[] bytes = out.toByteArray();

log.info("got bytes from input stream - byte[] size is "+ bytes.length);

对此的任何帮助将不胜感激。

谢谢。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值