我从FTP Server
using下载图像文件FTPClient
。我的样子是这样的:
public class FtpDownloadDemo
{
public static void main(String[] args)
{
FTPClient client = new FTPClient();
FileOutputStream fos = null;
try
{
client.connect("ftp.domain.com");
client.login("user", "pass");
//
// The remote filename to be downloaded.
//
String filename = "side.jpg";
fos = new FileOutputStream(filename);
//
// Download file from FTP server
//
client.retrieveFile("/" + filename, fos);
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
if (fos != null)
{
fos.close();
}
client.disconnect();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
下载文件后,输出看起来失真,如下所示;
有没有办法检查是否已收到所有字节,否则等到所有字节都收到?