2010-01-20 44 views
0

我正在使用javamail進行郵件應用程序。每一件事情都很好,但是當用戶下載附件時,他會得到確切的附件(好)。同時,在服務器中使用相同的文件名創建一個0字節的文件。使用java下載電子郵件附件

如何停止在服務器中創建0字節文件。

我的代碼是: -

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); 
+0

嘗試此: [http://stackoverflow.com/questions/1748183/download-attachments-using-java-mail][1] [1]:HTTP://計算器。 COM /問題/ 1748183 /下載附件,使用Java的郵件 – jag

回答

0

你有2個不同的(不相關的AFAICT)輸出流:outs(包裝fileoutput)和outoutsfileoutput似乎沒有被使用,但創建了空文件。