commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Johnson <>
Subject Re: [codec] My own little base64 implementation, as an {Input,Output}Stream.
Date Mon, 03 Nov 2003 20:18:14 GMT

Konstantin Priblouda wrote:

>--- Alexander Hvostov <> wrote:
>>A little while ago, I wrote a base64 {en,de}coder in
>>Java. Huzzah. Since I've 
>>found out that you guys wrote one too, I thought I
>>should submit mine. It's 
>>implemented as an OutputStream and InputStream pair,
>>though, so it's a bit 
>>different from yours, which is why I thought to send
>>mine. It's public 
>>domain, so do whatever you want with it. The two
>>source files are attached.
>That's really cool. I was playing with the same
>thoughts - I have
>to import / export binary content in XML, so it's
>really interesting.
>BTW, does somebody know XML parser, which works like
>but provides input stream of characters instead 
>callbak with a StringBuffer? Allocating big
>strings/arrays  is somehow uncool when you are about
>to save binary result into BLOB...
By which I think you're referring to org.xml.sax.ContentHandler? If the 
contents of an element includes a large blob of continuous text, the 
parsers are free to deliver this to your application in little chunks 
(and in fact do break it into chunks) so as to save on the maximum 
amount of memory the parser might be forced to allocate. Theoretically, 
it is then *your* problem to figure out whether or not it is a good idea 
to bundle all of the data up into a giant String or StringBuffer before 
you process it.

Nobody said the SAX API makes life easy. An interesting point, at least 
in the context of this discussion thread, is that you'd then need to 
pass the *characters* off to the base64 decoder, but in chunks of a size 
that the parser chooses, which unfortunately might not line up with the 
four-character chunks that a base64 decoder wants

Hope that helps.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message