Logo Search packages:      
Sourcecode: pcalendar version File versions  Download package

static String net::sf::linuxorg::pcal::common::Base64::encodeBytes ( byte[]  source,
int  off,
int  len,
int  options 
) throws java.io.IOException [inline, static]

Encodes a byte array into Base64 notation.

Example options:

   GZIP: gzip-compresses object before encoding it.
   DO_BREAK_LINES: break lines at 76 characters
     Note: Technically, this makes your encoding non-compliant.
 

Example: encodeBytes( myData, Base64.GZIP ) or

Example: encodeBytes( myData, Base64.GZIP | Base64.DO_BREAK_LINES )

As of v 2.3, if there is an error with the GZIP stream, the method will throw an java.io.IOException. This is new to v2.3! In earlier versions, it just returned a null value, but in retrospect that's a pretty poor way to handle it.

Parameters:
sourceThe data to convert
offOffset in array where conversion should begin
lenLength of data to convert
optionsSpecified options
Returns:
The Base64-encoded data as a String
See also:
Base64::GZIP
Base64::DO_BREAK_LINES
Exceptions:
java.io.IOExceptionif there is an error
NullPointerExceptionif source array is null
IllegalArgumentExceptionif source array, offset, or length are invalid
Since:
2.0

Definition at line 795 of file Base64.java.

References encodeBytesToBytes(), and PREFERRED_ENCODING.

                                                                                                                {
        byte[] encoded = encodeBytesToBytes( source, off, len, options );

        // Return value according to relevant encoding.
        try {
            return new String( encoded, PREFERRED_ENCODING );
        }   // end try
        catch (java.io.UnsupportedEncodingException uue) {
            return new String( encoded );
        }   // end catch
        
    }   // end encodeBytes

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index