download - Downloading an email attachment using java -
i doing mail application using javamail. every thing fine, when user downloading attachment, exact attachment (fine) .at same time 0 byte file creating in server same file name.
how stop creation of 0 byte files in server.
my code :-
attfile = new file(attname); fileoutputstream fileoutput = new fileoutputstream(attfile); inputstream = part.getinputstream(); bufferedoutputstream outs = new bufferedoutputstream(fileoutput); byte b[] = new byte[part.getsize()]; is.read(b); out = response.getoutputstream(); out.write(b);
you have 2 different (unrelated afaict) output streams: outs
(wrapping fileoutput
) , out
. outs
, fileoutput
not seem used create empty file.
Comments
Post a Comment