Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8164278

java.util.Base64.EncOutputStream/DecInputStream is slower than corresponding version in javax.mail package

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 11
    • None
    • core-libs
    • None
    • b01

      import javax.mail.internet.MimeUtility;
      import java.util.Base64;
      import java.io.*;

      public class Base64SpeedTest {
          public static void main(String[] argv) throws Exception {
      BufferedInputStream in = new BufferedInputStream(System.in);
      BufferedOutputStream out = new BufferedOutputStream(System.out);
      switch (argv[0]) {
      case "-encodejavamail":
      copy(in, MimeUtility.encode(out, "base64"));
      break;
      case "-encodejdk":
      copy(in, Base64.getMimeEncoder().wrap(out));
      break;
      case "-decodejavamail":
      copy(MimeUtility.decode(in, "base64"), out);
      break;
      case "-decodejdk":
      copy(Base64.getMimeDecoder().wrap(in), out);
      break;
      default:
      System.err.println("Bad option");
      System.exit(1);
      }
          }

          public static void copy(InputStream in, OutputStream out) throws IOException {
      byte[] buf = new byte[16*1024];
      int n;
      while ((n = in.read(buf)) > 0)
      out.write(buf, 0, n);
      out.flush();
          }
      }

            sherman Xueming Shen
            sherman Xueming Shen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: