v2.1 - Cleaned up javadoc comments and unused variables and methods. Added
some convenience methods for reading and writing to and from files.

v2.0.2 - Now specifies UTF-8 encoding in places where the code fails on systems
with other encodings (like EBCDIC).

v2.0.1 - Fixed an error when decoding a single byte, that is, when the
encoded data was a single byte.

v2.0 - I got rid of methods that used booleans to set options.
Now everything is more consolidated and cleaner. The code now detects
when data that's being decoded is gzip-compressed and will decompress it
automatically. Generally things are cleaner. You'll probably have to
change some method calls that you were making to support the new
options format (ints that you "OR" together).

v1.5.1 - Fixed bug when decompressing and decoding to a
byte[] using decode( String s, boolean gzipCompressed ).
Added the ability to "suspend" encoding in the Output Stream so
you can turn on and off the encoding if you need to embed base64
data in an otherwise "normal" stream (like an XML file).

v1.5 - Output stream pases on flush() command but doesn't do anything itself.
This helps when using GZIP streams.
Added the ability to GZip-compress objects before encoding them.

v1.4 - Added helper methods to read/write files.

v1.3.6 - Fixed OutputStream.flush() so that 'position' is reset.

v1.3.5 - Added flag to turn on and off line breaks. Fixed bug in input stream
where last buffer being read, if not completely full, was not returned.

I am placing this code in the Public Domain. Do with it as you will.
This software comes with no guarantees or warranties but with
plenty of well-wishing instead!
Please visit http://iharder.net/base64
periodically to check for updates or to contribute improvements.

Encodes up to the first three bytes of array threeBytes
and returns a four-byte array in Base64 notation.
The actual number of significant bytes in your array is
given by numSigBytes.
The array threeBytes needs only be as big as
numSigBytes.
Code can reuse a byte array by passing a four-byte array as b4.

Encodes up to three bytes of the array source
and writes the resulting four Base64 bytes to destination.
The source and destination arrays can be manipulated
anywhere along their length by specifying
srcOffset and destOffset.
This method does not check to make sure your arrays
are large enough to accomodate srcOffset + 3 for
the source array or destOffset + 4 for
the destination array.
The actual number of significant bytes in your array is
given by numSigBytes.

Serializes an object and returns the Base64-encoded
version of that serialized object. If the object
cannot be serialized or there is another error,
the method will return null.
The object is not GZip-compressed before being encoded.

Decodes four bytes from array source
and writes the resulting bytes (up to three of them)
to destination.
The source and destination arrays can be manipulated
anywhere along their length by specifying
srcOffset and destOffset.
This method does not check to make sure your arrays
are large enough to accomodate srcOffset + 4 for
the source array or destOffset + 3 for
the destination array.
This method returns the actual number of bytes that
were converted from the Base64 encoding.

Writes the byte to the output stream after
converting to/from Base64 notation.
When encoding, bytes are buffered three
at a time before the output stream actually
gets a write() call.
When decoding, bytes are buffered four
at a time.