public void writeToFile ( final File destination ) { InputStream input = null ; final OutputStream output ; try { input = getDataSource ( ) . getInputStream ( ) ; output = new FileOutputStream ( destination ) ; StreamUtil . copy ( input , output ) ; } catch ( final IOException ioex ) { throw new MailException ( ioex ) ; } finally { StreamUtil . close ( input ) ; } }
Saves attachment to a file .