62,628
社区成员
发帖
与我相关
我的任务
分享
File fileSendSrc = null;
File fileSendTemp = null;
File fileTrans = null;
BufferedInputStream bisSendSrc = null;
BufferedOutputStream bosSendTemp = null;
FileInputStream fileInputStreamTrans = null;
try {
fileSendSrc = new File(AFilePath); // 原文件A
fileSendTemp = new File(BFilePath); // 临时文件B
if (!fileSendTemp.exists()) {
fileSendTemp.createNewFile();
}
// 将原文件部分内容拷贝到临时文件
bisSendSrc = new BufferedInputStream(new FileInputStream(fileSendSrc));
bosSendTemp = new BufferedOutputStream(new FileOutputStream(fileSendTemp));
byte[] db = new byte[newfileLength];
bisSendSrc.read(db, 0, newfileLength); //读取文件A的部分内容到缓冲区db
bosSendTemp.write(db); //将缓冲区db中的内容写入到文件B
Application.closeStream(bosSendTemp); // 关闭流
bosSendTemp = null;
Application.closeStream(bisSendSrc); // 关闭流
bisSendSrc = null;
// 2.将临时文件上传FTP
// 切换远方Ftp服务器路径
m_FtpClient.changeWorkingDirectory(uploadInfo.romotepath);
fileTrans = new File(tmpfilepath);
fileInputStreamTrans = new FileInputStream(fileTrans);
if (m_FtpClient.storeFile(currentFileName, fileInputStreamTrans)) {
// 如果文件上传成功
bUploadSuccess = true;
} else {
bUploadSuccess = false;
}
Application.ThreadSleep(1000);
} catch (Exception e) {
bUploadSuccess = false;
} finally {
// 关闭流
Application.closeStream(bisSendSrc);
bisSendSrc= null;
Application.closeStream(bosSendTemp);
bosSendTemp = null;
Application.closeStream(fileInputStreamTrans);
fileInputStreamTrans = null;
}
我也是出现相同的问题,FTP上传图片时,在liunx环境下个别张的图片上传之后图片显示不全大小不同。然而再Windows服务器上就没出现过这个问题。代码如下:

public void close() throws IOException {
try {
flush();
} catch (IOException ignored) {
}
out.close();
}[/quote]out.close();也会抛出Exception的public void close() throws IOException {
try {
flush();
} catch (IOException ignored) {
}
out.close();
}public void close() throws IOException {
try {
flush();
} catch (IOException ignored) {
}
out.close();
}