FTPClient上传图片问题
卷心恒远 2009-06-16 11:36:46 我用FTPClient做了个图片上传,但图片经常上传不完整,有时只上传一半上去,有时就上传了个空图片
/*
* 上传文件
*/
public void upFile(InputStream in, String path, String saveFileName,
int fileSize) {
try {
FtpClient ftpClient = new FtpClient(host, 21); // 创建FTP服务类
ftpClient.login(username, password); // 登录FTP服务器
ftpClient.cd(path); // 图片目标目录
ftpClient.binary();
TelnetOutputStream telOut = ftpClient.put(saveFileName);
DataOutputStream out = new DataOutputStream(telOut);
byte[] b = new byte[fileSize];
int temp;
while ((temp = in.read(b)) != -1) {
out.write(b, 0, temp);
}
in.close();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
请各位高手帮个忙啊