我很难找出一些东西。 (我对这一切都很陌生。) 我写了这个java pgm来将一个大文件传输到目标服务器。 下面的代码(代码被修改了一下显示):FTP客户端问题
public static void ftpUpload(String path, String upfileName, String dirName) throws Exception
{
FTPClient client = new FTPClient();
client.addProtocolCommandListener((ProtocolCommandListener) new PrintCommandListener(new PrintWriter(System.out)));
client.enterLocalPassiveMode();
FileInputStream fis = null;
int reply;
try {
client.connect(ftpserver);
client.login(ftpuserid, ftppasswd);
reply = client.getReplyCode();
if(FTPReply.isPositiveCompletion(reply)){
client.changeWorkingDirectory(ftpdirectoryName + "/" + dirName);
boolean mkDir = client.makeDirectory(getCurrentMMMYY().toLowerCase());
client.changeWorkingDirectory(getCurrentMMMYY().toLowerCase());
//Create an InputStream of the file to be uploaded
fis = new FileInputStream(path + upfileName);
//Store file to server
client.storeFile(upfileName, fis);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
}
client.logout();
//client.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
奇怪的事情正在发生的事情对我送的文件... 我的一个始发服务器上的文件是82575786的大小,当我ftp这个文件它几乎发送整个文件。它实际上发送82574867.(缺少919) 始发服务器上的另一个文件是717885,当我ftp这个文件时,它几乎发送整个文件。它实际上发送717522.(错过363)
我拉了日志,看看是否有东西坠毁,但它没有显示任何错误的转移。以下是显示传输的2个日志条目。
[08/09/11 20:21:13:618 EDT] 00000043 SystemOut O 221 - 您已在1个文件中传输了717522个字节。 221 - 您已经在1个文件中传输了82574867个字节。
任何人的帮助将不胜感激。感谢 丹。
我可能会问你为什么要使用输入与outpustream ,所以发送文件只有一个输入流,它不工作?谢谢! – 98percentmonkey