Package org.apache.james.mime4j.decoder

Examples of org.apache.james.mime4j.decoder.Base64OutputStream


    String str_encoded = "QmFzZTY0IEVuY29kaW5nIGlzIGEgcG9wdWxhciB3YXkgdG8gY29udmVydCB0aGUgOGJpdCBhbmQgdGhlIGJpbmFyeSB0byB0aGUgN2JpdCBmb3IgbmV0d29yayB0cmFucyB1c2luZyBTb2NrZXQsIGFuZCBhIHNlY3VyaXR5IG1ldGhvZCB0byBoYW5kbGUgdGV4dCBvciBmaWxlLCBvZnRlbiB1c2VkIGluIEF1dGhlbnRpY2FsIExvZ2luIGFuZCBNYWlsIEF0dGFjaG1lbnQsIGFsc28gc3RvcmVkIGluIHRleHQgZmlsZSBvciBkYXRhYmFzZS4gTW9zdCBTTVRQIHNlcnZlciB3aWxsIGhhbmRsZSB0aGUgbG9naW4gVXNlck5hbWUgYW5kIFBhc3N3b3JkIGluIHRoaXMgd2F5Lg==";
   
    // create a Base64OutputStream
    StringWriter strwriter = new StringWriter();
    BufferedWriter buffwriter = new BufferedWriter(strwriter);
    Base64OutputStream b64_out = new Base64OutputStream(buffwriter);
   
    byte[] b = str.getBytes();
   
    // write the bytes in different lengths to test whether leftover
    // data is persisted across calls to write
    b64_out.write(b, 0, 33);
    b64_out.write(b, 33, 1);
    b64_out.write(b, 34, 1);
    b64_out.write(b, 35, 2);
    b64_out.write(b, 37, 3);
    b64_out.write(b, 40, 3);
    b64_out.write(b, 43, 3);
    b64_out.write(b, 46, 5);
    b64_out.write(b, 51, 4);
    b64_out.write(b, 55, 5);
    b64_out.write(b, 60, 6);
    b64_out.write(b, 66, 10);
    b64_out.write(b, 76, 51);
    b64_out.write(b, 127, 150);
    b64_out.write(b, 277, 22);
    b64_out.write(b, 299, 21);
    b64_out.write(b, 320, 2);
   
    // remember to add padding characters (if necessary)
    b64_out.close();
   
    // compare the contents of the outputstream with the expected encoded string
    assertEquals(strwriter.toString(), str_encoded)
 
View Full Code Here


   
    byte[] bytes = str.getBytes();
   
    StringWriter strwriter = new StringWriter();
    BufferedWriter buffwriter = new BufferedWriter(strwriter);
    Base64OutputStream b64_out = new Base64OutputStream(buffwriter);
   
    GZIPOutputStream zip = new GZIPOutputStream(b64_out);
   
    zip.write(bytes, 0, bytes.length);
    zip.finish();
    buffwriter.flush();
    b64_out.close();
   
    assertEquals(str_encoded, strwriter.toString());
   
  }
View Full Code Here

  private void _testWriteChar(String str, String str_encoded) throws IOException
  {
    // create a Base64OutputStream
    StringWriter strwriter = new StringWriter();
    BufferedWriter buffwriter = new BufferedWriter(strwriter);
    Base64OutputStream b64_out = new Base64OutputStream(buffwriter);
   
    // write out each char in str to the stream
    for (int i = 0; i<str.length(); i++)
    {
      b64_out.write(str.charAt(i));
    }
    // remember to add padding characters (if necessary)
    b64_out.close();
       
    // compare the contents of the outputstream with the expected encoded string
    assertEquals(strwriter.toString(), str_encoded)
  }
View Full Code Here

  private void _testWriteArray(String str, String str_encoded) throws IOException
 
    // create a Base64OutputStream
    StringWriter strwriter = new StringWriter();
    BufferedWriter buffwriter = new BufferedWriter(strwriter);
    Base64OutputStream b64_out = new Base64OutputStream(buffwriter);
   
    // convert str into an array of bytes
    byte[] b = str.getBytes();
   
    // write out the array to the output stream
    b64_out.write(b, 0, b.length);
    // append padding chars if necessary
    b64_out.close();
   
    //     System.out.println("testwriteArray,  expected encoding:" + str_encoded);   
    //         System.out.println("testwriteArray, output of encoding:" + strwriter.toString());
   
    // compare the contents of the outputstream with the expected encoded string
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.decoder.Base64OutputStream

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.