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

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

linq to sql - Linq2EF: Return DateTime with a TimeZone Offset -

gdi+ - WxWidgets draw a bitmap with opacity -