Package com.oreilly.servlet

Examples of com.oreilly.servlet.Base64Encoder


    out.append("Content-Disposition: attachment;").append(CRLF);
    out.append(" filename=\"").append(sStrippedFileName).append("\"").append(CRLF);

    out.append(CRLF);
   
    Base64Encoder encoder = null;

    try {
      final ByteArrayOutputStream baos = new ByteArrayOutputStream();
     
      encoder = new Base64Encoder(baos);

      final byte[] buf = new byte[4 * 1024]; // 4K buffer
      int bytesRead;

      while ((bytesRead = in.read(buf)) != -1) {
        encoder.write(buf, 0, bytesRead);
      }
     
      encoder.flush();
     
      out.append(baos.toString("US-ASCII"));
    }
    catch (Throwable e) {
      Log.log(Log.FATAL, "lazyj.mail.Sendmail", "writeAttachment" + e);
      this.iSentOk = SENT_ERROR;
      this.sError = "exception while writing an attachment : " + e.getMessage();
      return false;
    }
    finally{
      if (in != null)
        try{
          in.close();
        }
        catch (IOException e){
          // ignore
        }
     
      if (encoder != null){
        try{
          encoder.close();
        }
        catch (IOException e){
          // ignore
        }
      }
View Full Code Here

TOP

Related Classes of com.oreilly.servlet.Base64Encoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.