Hi,
I know of a good Base64InputStream for commons-codec. It can encode
and decode. It uses the Base64 class from commons-codec under the
hood. It works like this:
-------------------------------------------
final boolean DECODE = true;
final boolean ENCODE = false;
InputStream in = new FileInputStream("file.base64");
in = new Base64InputStream(in, DECODE);
-------------------------------------------
I ran some performance tests (decode 699MB file) against some other
Base64 implementations:
1. [60.507 seconds] http://iharder.sourceforge.net/base64/
2. [69.311 seconds] sun.misc.BASE64Decoder
3. [31.018 seconds] "openssl enc -base64 -d" (non-java unix command)
4. [30.865 seconds] not-yet-commons-ssl THE WINNER!!!!
- Core 2 Duo 2.8ghz on Mac Leopard
- Sun's 1.5.0_13 with "-server"
- Full 700MB was decoded three times in a single go (no JVM restarts).
The shortest time for each is printed above.
- Files created by the 4 techniques compared using md5sum. All look same.
- BufferedInputStream and BufferedOutputStream wrappers.
- (If I may brag: not-yet-commons-ssl performance doesn't change if
BufferedInputStream / BufferedOutputStream aren't used. The other
libraries really suffer - like 20 times slower!)
I also tried to test with ws-common, but the Base64 library in there
doesn't have a streaming decoder, so I don't think it can handle a
700MB file.
Here's the code:
http://juliusdavies.ca/svn/viewvc.cgi/not-yet-commons-ssl/trunk/src/java/org/apache/commons/ssl/Base64InputStream.java?view=markup
I should mention one thing.... a huge IO bottleneck was fixed in
not-yet-commons-ssl by doing this:
byte[] line = readLine.nextAsBytes(100);
ReadLine is a special byte[] oriented line-reader. In this case I'm
telling it "give me next 100 lines as byte[] if possible, with
line-endings stripped off." If the commons-codec project is
interested in something like this, I think ReadLine has to come along,
too.
By the way, I'm just querying the mailing list here for interest. The
Base64InputStream.java code in not-yet-commons-ssl needs javadocs
before it can come over.
And.... good work on org.apache.commons.codec.binary.Base64! I was
really astonished to see us beat openssl!
--
yours,
Julius Davies
250-592-2284 (Home)
250-893-4579 (Mobile)
http://juliusdavies.ca/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]