Lendo email com JavaMail - problema com nome de arquivo anexado com caracteres especiais

Olá a todos.

Eu estou desenvolvendo uma aplicação que verifica as mensagens em uma caixa de email e salvar os anexo existentes.
Tudo funciona bem até que a aplicação tenta obter da mensagem um arquivo contendo um anexo com caracteres especias como:
Documento de EspecificaÇÂO.doc

Eu percebi que na mesagem o arquivo chega com o seguinte nome:
“=?iso-8859-1?Q?Documento_de_Especifica=E7=E3o_de_Requisitos.doc?=”


package br.com.cesan.helpdesk;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Part;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.search.FlagTerm;

public class LerEmail2 {

	/**
	 * @param args
	 * @throws MessagingException 
	 * @throws IOException 
	 */
	public static void main(String[] args) throws MessagingException, IOException {
		// TODO Auto-generated method stub
		
		// Get session
	    Session session = Session.getInstance(new Properties(), null);

	    // Get the store
	    Store store = session.getStore("pop3");
	    store.connect("pop.xxxx.com.br", "usuario", "senha");
	    
	    Folder folder = store.getFolder("INBOX");
		//folder.open(Folder.READ_ONLY); 
		folder.open(Folder.READ_WRITE);
		
		// Show only unreaded Messages
		FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false);

		
		// Get directory
	    Message message[] = folder.getMessages();	    
	    //Message messages[] = folder.search(ft);

	    
	    for (int i=0, n=message.length; i<n; i++) {
	    	
	    	System.out.println(i + ": [" + message[i].getFrom()[0] +"]"
	    						+ " [ " + message[i].getSubject() +"]"
	    						+ " [ " + message[i].getSubject() +"]"
	    						+ " [" + message[i].getSentDate() +"]"
	    			);
	    	
	    	 Object content = message[i].getContent();

	    	 if (content instanceof Multipart) {
	             handleMultipart((Multipart)content);
	         } else {
	             handlePart(message[i]);
	         }

	    	
	    }
	    
	    
	    // Close connection 
	    folder.close(false);
	    store.close();
		
	}
	
	public static void handleMultipart(Multipart multipart) throws MessagingException, IOException {

		for (int i=0, n=multipart.getCount(); i><n; i++) {
			handlePart(multipart.getBodyPart(i));
		}
	}

	
	public static void handlePart(Part part) throws MessagingException, IOException {
	    
		String disposition = part.getDisposition();
	    String contentType = part.getContentType();
	   
	    if (disposition == null) { // When just body
	      
	    	System.out.println("Null: "  + contentType);
	     
	    	// Check if plain
	    	if ((contentType.length() >= 10) && (contentType.toLowerCase().substring(0, 10).equals("text/plain"))) {
	    		part.writeTo(System.out);
	    	
	    	} else { // Don't think this will happen
	    		System.out.println("Other body: " + contentType);
	    		part.writeTo(System.out);
	    	}
	      
	    } else if (disposition.equalsIgnoreCase(Part.ATTACHMENT)) {
	      
	    	System.out.println("Attachment: " + part.getFileName() + " : " + contentType);
	    	saveFile(part.getFileName(), part.getInputStream());
	      
	    } else if (disposition.equalsIgnoreCase(Part.INLINE)) {
	      System.out.println("Inline: " + 
	        part.getFileName() + 
	        " : " + contentType);
	      saveFile(part.getFileName(), part.getInputStream());
	    } else {  // Should never happen
	      System.out.println("Other: " + disposition);
	    }
	    
	}

	
	public static void saveFile(String filename, InputStream input) throws IOException {
			
		if (filename == null) {
			filename = File.createTempFile("xx", ".out").getName();
		}
		    
		// Do no overwrite existing file
		File file = new File(filename);

		for (int i=0; file.exists(); i++) {
			file = new File(filename+i);
		}
		
		System.setProperty("file.encoding", "iso-8859-1"); 
		
		FileOutputStream fos = new FileOutputStream(file);
		BufferedOutputStream bos = new BufferedOutputStream(fos);

		BufferedInputStream bis = new BufferedInputStream(input);
		int aByte;
		while ((aByte = bis.read()) != -1) {
			bos.write(aByte);
		}
		
		bos.flush();
		bos.close();
		bis.close();
	}

}

O problema acontece na linha:

FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);

BufferedInputStream bis = new BufferedInputStream(input);
int aByte;
while ((aByte = bis.read()) != -1) {
   bos.write(aByte);
}

Alguêm já passou por isto?

Obs: Eu estou usando a API javamail1.4.5

Obrigado

“=?iso-8859-1?Q?Documento_de_Especifica=E7=E3o_de_Requisitos.doc?=” é o jeito correto de codificar o nome do documento, no formato MIME.

?iso-8859-1?Q? indica que o que vem a seguir, até o próximo ?=, está codificado em ISO-8859-1. Quando você encontra um =, os 2 dígitos depois são a representação hexadecimal, em ISO-8859-1, do caracter. Por exemplo, em ISO-8859-1, o caracter E7 representa “ç” e o caracter E3 representa “ã”.

Só uma perguntinha: o que realmente está vindo em part.getFileName()?
Se você está imprimindo em um console com System.out.println, pode ser que fique distorcido mesmo.
No caso do Windows, se você não digitar o comando “chcp 1252” antes de rodar o programa, para mudar o conjunto padrão de caracteres do console, vai aparecer algo como
þ para o E7, Ò para o E3.

Tente criar o arquivo, em vez de só imprimir na tela, e veja se o arquivo está sendo mesmo criado com o nome desejado.

de uma olhada em http://programmerexpert.blogspot.com.br/2012/08/padrao-te-texto-mime.html, já mostra como resolver