L2JPREMIUM  5M
com.premium.Base64 Class Reference

Classes

class  InputStream
 
class  OutputStream
 

Static Public Member Functions

static void main (String[] args) throws IOException
 
static String encodeObject (java.io.Serializable serializableObject)
 
static String encodeObject (java.io.Serializable serializableObject, int options)
 
static String encodeBytes (byte[] source)
 
static String encodeBytes (byte[] source, int options)
 
static String encodeBytes (byte[] source, int off, int len)
 
static String encodeBytes (byte[] source, int off, int len, int options)
 
static byte[] decode (byte[] source, int off, int len)
 
static byte[] decode (String s)
 
static Object decodeToObject (String encodedObject)
 

Static Public Attributes

static final int NO_OPTIONS = 0
 
static final int ENCODE = 1
 
static final int DECODE = 0
 
static final int GZIP = 2
 
static final int DONT_BREAK_LINES = 8
 

Detailed Description

Encodes and decodes to and from Base64 notation. The source is based on the work of Robert Harder

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.

Author
Robert Harder
rob@i.nosp@m.hard.nosp@m.er.ne.nosp@m.t
Version
2.0

Member Function Documentation

◆ decode() [1/2]

static byte [] com.premium.Base64.decode ( byte[]  source,
int  off,
int  len 
)
inlinestatic

Very low-level access to decoding ASCII characters in the form of a byte array. Does not support automatically gunzipping or any other "fancy" features.

Parameters
sourceThe Base64 encoded data
offThe offset of where to begin decoding
lenThe length of characters to decode
Returns
decoded data
Since
1.3

◆ decode() [2/2]

static byte [] com.premium.Base64.decode ( String  s)
inlinestatic

Decodes data from Base64 notation, automatically detecting gzip-compressed data and decompressing it.

Parameters
sthe string to decode
Returns
the decoded data
Since
1.4

◆ decodeToObject()

static Object com.premium.Base64.decodeToObject ( String  encodedObject)
inlinestatic

Attempts to decode Base64 data and deserialize a Java Object within. Returns null if there was an error.

Parameters
encodedObjectThe Base64 data to decode
Returns
The decoded and deserialized object
Since
1.5

◆ encodeBytes() [1/4]

static String com.premium.Base64.encodeBytes ( byte[]  source)
inlinestatic

Encodes a byte array into Base64 notation. Does not GZip-compress data.

Parameters
sourceThe data to convert
Returns
Since
1.4

◆ encodeBytes() [2/4]

static String com.premium.Base64.encodeBytes ( byte[]  source,
int  off,
int  len 
)
inlinestatic

Encodes a byte array into Base64 notation. Does not GZip-compress data.

Parameters
sourceThe data to convert
offOffset in array where conversion should begin
lenLength of data to convert
Returns
Since
1.4

◆ encodeBytes() [3/4]

static String com.premium.Base64.encodeBytes ( byte[]  source,
int  off,
int  len,
int  options 
)
inlinestatic

Encodes a byte array into Base64 notation.

Valid options:

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

<p<blockquote>

Example: encodeBytes( myData, Base64.GZIP ) or

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

Parameters
sourceThe data to convert
offOffset in array where conversion should begin
lenLength of data to convert
optionsSpecified options
Returns
See also
Base64::GZIP
Base64::DONT_BREAK_LINES
Since
2.0

◆ encodeBytes() [4/4]

static String com.premium.Base64.encodeBytes ( byte[]  source,
int  options 
)
inlinestatic

Encodes a byte array into Base64 notation.

Valid options:

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

<p<blockquote>

Example: encodeBytes( myData, Base64.GZIP ) or

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

Parameters
sourceThe data to convert
optionsSpecified options
Returns
See also
Base64::GZIP
Base64::DONT_BREAK_LINES
Since
2.0

◆ encodeObject() [1/2]

static String com.premium.Base64.encodeObject ( java.io.Serializable  serializableObject)
inlinestatic

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.

Parameters
serializableObjectThe object to encode
Returns
The Base64-encoded object
Since
1.4

◆ encodeObject() [2/2]

static String com.premium.Base64.encodeObject ( java.io.Serializable  serializableObject,
int  options 
)
inlinestatic

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.

Valid options:

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

<p<blockquote>

Example: encodeObject( myObj, Base64.GZIP ) or

Example: encodeObject( myObj, Base64.GZIP | Base64.DONT_BREAK_LINES )

Parameters
serializableObjectThe object to encode
options@options Specified options
Returns
The Base64-encoded object
See also
Base64::GZIP
Base64::DONT_BREAK_LINES
Since
2.0

Member Data Documentation

◆ DECODE

final int com.premium.Base64.DECODE = 0
static

Specify decoding.

◆ DONT_BREAK_LINES

final int com.premium.Base64.DONT_BREAK_LINES = 8
static

Don't break lines when encoding (violates strict Base64 specification)

◆ ENCODE

final int com.premium.Base64.ENCODE = 1
static

Specify encoding.

◆ GZIP

final int com.premium.Base64.GZIP = 2
static

Specify that data should be gzip-compressed.

◆ NO_OPTIONS

final int com.premium.Base64.NO_OPTIONS = 0
static

No options specified. Value is zero.


The documentation for this class was generated from the following file: