I am doing a mail application using javamail. Every thing is fine, but when the user is downloading the attachment, he will get the exact attachment (fine) .at the same time a 0 byte file is creating in the server with same file name.
我正在使用javamail做一个邮件应用程序。一切都很好,但是当用户下载附件时,他将获得确切的附件(精细)。同时在具有相同文件名的服务器中创建一个0字节文件。
How do i stop creation of 0 byte files in the server.
如何停止在服务器中创建0字节文件。
my code is :-
我的代码是: -
attFile = new File(attname);
FileOutputStream fileoutput = new FileOutputStream(attFile);
InputStream is = part.getInputStream();
BufferedOutputStream outs = new BufferedOutputStream(fileoutput);
byte b[] = new byte[part.getSize()];
is.read(b);
out = response.getOutputStream();
out.write(b);
1 个解决方案
#1
0
You have 2 different (unrelated AFAICT) output streams: outs
(wrapping fileoutput
) and out
. outs
and fileoutput
do not seem to be used but create the empty file.
您有2个不同的(不相关的AFAICT)输出流:outs(包装fileoutput)和out。似乎没有使用outs和fileoutput但是创建了空文件。
#1
0
You have 2 different (unrelated AFAICT) output streams: outs
(wrapping fileoutput
) and out
. outs
and fileoutput
do not seem to be used but create the empty file.
您有2个不同的(不相关的AFAICT)输出流:outs(包装fileoutput)和out。似乎没有使用outs和fileoutput但是创建了空文件。