@@ -611,46 +611,44 @@ private String getNextMessage(String sTime, String sPrefix, boolean end)
611
611
return "--" + getStartMessage (sTime , sPrefix ) + (end ?"--" :"" );
612
612
}
613
613
614
- private void sendAttachment (String sTime , String fileNamePath , String attachmentPath ) throws GXMailException , IOException
615
- {
614
+ private void sendAttachment (String sTime , String fileNamePath , String attachmentPath ) throws GXMailException , IOException {
616
615
InputStream is = null ;
617
616
String fileName = fileNamePath ;
618
617
FileInputStream fis = null ;
619
618
620
- if (fileNamePath .lastIndexOf (File .separator ) != -1 )
619
+ if (fileNamePath .lastIndexOf (File .separator ) != -1 )
621
620
fileName = fileNamePath .substring (fileNamePath .lastIndexOf (File .separator ) + 1 );
622
621
623
- try {
624
- fis = new FileInputStream (attachmentPath + fileNamePath );
625
- is = fis ;
626
- }
627
- catch (FileNotFoundException e ) {
628
- log ("11 - FileNotFound " + e .getMessage ());
622
+ try {
623
+ fis = new FileInputStream (attachmentPath + fileNamePath );
624
+ is = fis ;
625
+
626
+ println (getNextMessageIdMixed (sTime , false ));
627
+ println ("Content-Type: " + "application/octet-stream" );
628
+ println ("Content-Transfer-Encoding: " + "base64" );
629
+ println ("Content-Disposition: " + "attachment; filename=\" " + GXMailer .getEncodedString (fileName ) + "\" " );
630
+ println ("" );
631
+
632
+ int BUFFER_SIZE = 4096 ;
633
+ byte [] buffer = new byte [BUFFER_SIZE ];
634
+ OutputStream base64Output = new Base64OutputStream (outStream );
635
+ int n = is .read (buffer , 0 , BUFFER_SIZE );
636
+ while (n >= 0 ) {
637
+ base64Output .write (buffer , 0 , n );
638
+ n = is .read (buffer , 0 , BUFFER_SIZE );
639
+ }
640
+ base64Output .flush ();
641
+ outStream .writeBytes (CRLF );
642
+ outStream .flush ();
643
+ } catch (FileNotFoundException e ) {
644
+ log ("11 - FileNotFound " + e .getMessage ());
629
645
throw new GXMailException ("Can't find " + attachmentPath + fileNamePath , MAIL_InvalidAttachment );
630
646
} finally {
631
- if (is != null )
632
- is .close ();
633
- if (fis != null )
634
- fis .close ();
647
+ if (is != null )
648
+ is .close ();
649
+ if (fis != null )
650
+ fis .close ();
635
651
}
636
-
637
- println (getNextMessageIdMixed (sTime , false ));
638
- println ("Content-Type: " + "application/octet-stream" );
639
- println ("Content-Transfer-Encoding: " + "base64" );
640
- println ("Content-Disposition: " + "attachment; filename=\" " + GXMailer .getEncodedString (fileName ) + "\" " );
641
- println ("" );
642
-
643
- int BUFFER_SIZE = 4096 ;
644
- byte [] buffer = new byte [BUFFER_SIZE ];
645
- OutputStream base64Output = new Base64OutputStream (outStream );
646
- int n = is .read (buffer , 0 , BUFFER_SIZE );
647
- while (n >= 0 ) {
648
- base64Output .write (buffer , 0 , n );
649
- n = is .read (buffer , 0 , BUFFER_SIZE );
650
- }
651
- base64Output .flush ();
652
- outStream .writeBytes (CRLF );
653
- outStream .flush ();
654
652
}
655
653
656
654
private void println (String s ) throws IOException
0 commit comments