views:

96

answers:

1

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);
A: 

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