0

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.

How do i stop creation of 0 byte files in the server.

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);
Svetlozar Angelov
  • 21,214
  • 6
  • 62
  • 67
surya
  • 1
  • Try this : [http://stackoverflow.com/questions/1748183/download-attachments-using-java-mail][1] [1]: http://stackoverflow.com/questions/1748183/download-attachments-using-java-mail – jag Jul 20 '15 at 13:06

1 Answers1

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.

jackrabbit
  • 5,525
  • 1
  • 27
  • 38