net.i2p.data
Class DataHelper

java.lang.Object
  extended by net.i2p.data.DataHelper

public class DataHelper
extends java.lang.Object

Defines some simple IO routines for dealing with marshalling data structures

Author:
jrandom

Field Summary
static byte BOOLEAN_FALSE
          deprecated - used only in DatabaseLookupMessage
static int BOOLEAN_LENGTH
          Deprecated. unused
static byte BOOLEAN_TRUE
          deprecated - used only in DatabaseLookupMessage
static byte BOOLEAN_UNKNOWN
          Deprecated. unused
static int DATE_LENGTH
           
static int MAX_COMPRESSION
           
static int NO_COMPRESSION
           
 
Constructor Summary
DataHelper()
           
 
Method Summary
static int compareTo(byte[] lhs, byte[] rhs)
          treat bytes as unsigned
static byte[] compress(byte[] orig)
          compress the data and return a new GZIP compressed array
static byte[] compress(byte[] orig, int offset, int size)
           
static byte[] compress(byte[] orig, int offset, int size, int level)
           
static byte[] decompress(byte[] orig)
          decompress the GZIP compressed data (returning null on error)
static byte[] decompress(byte[] orig, int offset, int length)
           
static boolean eq(byte[] lhs, byte[] rhs)
          Run a comparison on the byte arrays, byte by byte.
static boolean eq(byte[] lhs, int offsetLeft, byte[] rhs, int offsetRight, int length)
           
static boolean eq(byte lhs, byte rhs)
          Deprecated. inefficient
static boolean eq(java.util.Collection lhs, java.util.Collection rhs)
          Run a deep comparison across the two collections.
static boolean eq(int lhs, int rhs)
          Deprecated. inefficient
static boolean eq(long lhs, long rhs)
          Deprecated. inefficient
static boolean eq(java.lang.Object lhs, java.lang.Object rhs)
          Helper util to compare two objects, including null handling.
static java.lang.String formatDuration(long ms)
           
static java.lang.String formatSize(long bytes)
          Caller should append 'B' or 'b' as appropriate
static java.lang.String formatSize2(long bytes)
          Like formatSize but with a space after the number
static java.lang.Boolean fromBoolean(byte[] data, int offset)
          Deprecated. unused
static java.util.Date fromDate(byte[] src, int offset)
           
static byte[] fromHexString(java.lang.String val)
           
static long fromLong(byte[] src, int offset, int numBytes)
           
static int fromProperties(byte[] source, int offset, java.util.Properties target)
          Deprecated. unused
static java.lang.String getUTF8(byte[] orig)
           
static java.lang.String getUTF8(byte[] orig, int offset, int len)
           
static byte[] getUTF8(java.lang.String orig)
           
static byte[] getUTF8(java.lang.StringBuffer orig)
           
static int hashCode(byte[] b)
          Calculate the hashcode of the byte array, using 0 for null
static int hashCode(java.util.Collection col)
          Calculate the hashcode of the collection, using 0 for null
static int hashCode(java.util.Date obj)
          Calculate the hashcode of the date, using 0 for null
static int hashCode(java.lang.Object obj)
          Calculate the hashcode of the object, using 0 for null
static void loadProps(java.util.Properties props, java.io.File file)
          A more efficient Properties.load Some of the other differences: - This does not process or drop backslashes - '#' or ';' starts a comment line, but '!'
static void loadProps(java.util.Properties props, java.io.File file, boolean forceLowerCase)
           
static void loadProps(java.util.Properties props, java.io.InputStream inStr)
           
static void loadProps(java.util.Properties props, java.io.InputStream inStr, boolean forceLowerCase)
           
static int read(java.io.InputStream in, byte[] target)
           
static int read(java.io.InputStream in, byte[] target, int offset, int length)
           
static java.lang.Boolean readBoolean(java.io.InputStream in)
          Deprecated. unused
static java.util.Date readDate(java.io.InputStream in)
          Read in a date from the stream as specified by the I2P data structure spec.
static java.lang.String readLine(java.io.InputStream in)
          Read a newline delimited line from the stream, returning the line (without the newline), or null if EOF reached before the newline was found Warning - strips \n but not \r Warning - 8KB line length limit as of 0.7.13, @throws IOException if exceeded
static java.lang.String readLine(java.io.InputStream in, Sha256Standalone hash)
          update the hash along the way Warning - strips \n but not \r Warning - 8KB line length limit as of 0.7.13, @throws IOException if exceeded
static boolean readLine(java.io.InputStream in, java.lang.StringBuffer buf)
          Deprecated. use StringBuilder version
static boolean readLine(java.io.InputStream in, java.lang.StringBuffer buf, Sha256Standalone hash)
          Deprecated. use StringBuilder version
static boolean readLine(java.io.InputStream in, java.lang.StringBuilder buf)
          Read in a line, placing it into the buffer (excluding the newline).
static boolean readLine(java.io.InputStream in, java.lang.StringBuilder buf, Sha256Standalone hash)
          update the hash along the way Warning - strips \n but not \r Warning - 8KB line length limit as of 0.7.13, @throws IOException if exceeded
static long readLong(java.io.InputStream rawStream, int numBytes)
          Read the stream for an integer as defined by the I2P data structure specification.
static java.util.Properties readProperties(java.io.InputStream rawStream)
          Read a mapping from the stream, as defined by the I2P data structure spec, and store it into a Properties object.
static java.lang.String readString(java.io.InputStream in)
          Read in a string from the stream as specified by the I2P data structure spec.
static java.util.List<? extends DataStructure> sortStructures(java.util.Collection<? extends DataStructure> dataStructures)
          Sort based on the Hash of the DataStructure Warning - relatively slow.
static void storeProps(java.util.Properties props, java.io.File file)
          Writes the props to the file, unsorted (unless props is an OrderedProperties) Note that this does not escape the \r or \n that are unescaped in loadProps() above.
static java.lang.String stripHTML(java.lang.String orig)
          Strip out any HTML (simply removing any less than / greater than symbols)
static void toBoolean(byte[] data, int offset, boolean value)
          Deprecated. unused
static void toBoolean(byte[] data, int offset, java.lang.Boolean value)
          Deprecated. unused
static void toDate(byte[] target, int offset, long when)
           
static byte[] toDate(java.util.Date date)
           
static java.lang.String toDecimalString(byte[] buf, int len)
           
static java.lang.String toHexString(byte[] data)
           
static void toLong(byte[] target, int offset, int numBytes, long value)
           
static byte[] toLong(int numBytes, long value)
           
static int toProperties(byte[] target, int offset, java.util.Properties props)
           
static byte[] toProperties(java.util.Properties opts)
          Deprecated. unused
static java.lang.String toString(byte[] buf)
           
static java.lang.String toString(byte[] buf, int len)
           
static java.lang.String toString(java.util.Collection col)
          Pretty print the collection
static java.lang.String toString(java.util.Properties options)
          Pretty print the mapping, unsorted (unless the options param is an OrderedProperties)
static void write(java.io.OutputStream out, byte[] data, Sha256Standalone hash)
           
static void writeBoolean(java.io.OutputStream out, java.lang.Boolean bool)
          Deprecated. unused
static void writeDate(java.io.OutputStream out, java.util.Date date)
          Write out a date to the stream as specified by the I2P data structure spec.
static void writeLong(java.io.OutputStream rawStream, int numBytes, long value)
          Write an integer as defined by the I2P data structure specification to the stream.
static void writeProperties(java.io.OutputStream rawStream, java.util.Properties props)
          Write a mapping to the stream, as defined by the I2P data structure spec, and store it into a Properties object.
static void writeProperties(java.io.OutputStream rawStream, java.util.Properties props, boolean utf8)
          Writes the props to the stream, sorted by property name.
static void writeString(java.io.OutputStream out, java.lang.String string)
          Write out a string to the stream as specified by the I2P data structure spec.
static byte[] xor(byte[] lhs, byte[] rhs)
           
static void xor(byte[] lhs, int startLeft, byte[] rhs, int startRight, byte[] out, int startOut, int len)
          xor the lhs with the rhs, storing the result in out.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATE_LENGTH

public static final int DATE_LENGTH
See Also:
Constant Field Values

BOOLEAN_TRUE

public static final byte BOOLEAN_TRUE
deprecated - used only in DatabaseLookupMessage

See Also:
Constant Field Values

BOOLEAN_FALSE

public static final byte BOOLEAN_FALSE
deprecated - used only in DatabaseLookupMessage

See Also:
Constant Field Values

BOOLEAN_UNKNOWN

public static final byte BOOLEAN_UNKNOWN
Deprecated. unused
See Also:
Constant Field Values

BOOLEAN_LENGTH

public static final int BOOLEAN_LENGTH
Deprecated. unused
See Also:
Constant Field Values

MAX_COMPRESSION

public static final int MAX_COMPRESSION
See Also:
Constant Field Values

NO_COMPRESSION

public static final int NO_COMPRESSION
See Also:
Constant Field Values
Constructor Detail

DataHelper

public DataHelper()
Method Detail

readProperties

public static java.util.Properties readProperties(java.io.InputStream rawStream)
                                           throws DataFormatException,
                                                  java.io.IOException
Read a mapping from the stream, as defined by the I2P data structure spec, and store it into a Properties object. A mapping is a set of key / value pairs. It starts with a 2 byte Integer (ala readLong(rawStream, 2)) defining how many bytes make up the mapping. After that comes that many bytes making up a set of UTF-8 encoded characters. The characters are organized as key=value;. The key is a String (ala readString(rawStream)) unique as a key within the current mapping that does not include the UTF-8 characters '=' or ';'. After the key comes the literal UTF-8 character '='. After that comes a String (ala readString(rawStream)) for the value. Finally after that comes the literal UTF-8 character ';'. This key=value; is repeated until there are no more bytes (not characters!) left as defined by the first two byte integer.

Parameters:
rawStream - stream to read the mapping from
Returns:
mapping
Throws:
DataFormatException - if the format is invalid
java.io.IOException - if there is a problem reading the data

writeProperties

public static void writeProperties(java.io.OutputStream rawStream,
                                   java.util.Properties props)
                            throws DataFormatException,
                                   java.io.IOException
Write a mapping to the stream, as defined by the I2P data structure spec, and store it into a Properties object. See readProperties for the format. Property keys and values must not contain '=' or ';', this is not checked and they are not escaped Keys and values must be 255 bytes or less, Formatted length must not exceed 65535 bytes

Parameters:
rawStream - stream to write to
props - properties to write out
Throws:
DataFormatException - if either is too long.
DataFormatException - if there is not enough valid data to write out
java.io.IOException - if there is an IO error writing out the data

writeProperties

public static void writeProperties(java.io.OutputStream rawStream,
                                   java.util.Properties props,
                                   boolean utf8)
                            throws DataFormatException,
                                   java.io.IOException
Writes the props to the stream, sorted by property name. See readProperties() for the format. Property keys and values must not contain '=' or ';', this is not checked and they are not escaped Keys and values must be 255 bytes or less, Formatted length must not exceed 65535 bytes

Throws:
DataFormatException - if either is too long. jrandom disabled UTF-8 in mid-2004, for performance reasons, i.e. slow foo.getBytes("UTF-8") Re-enable it so we can pass UTF-8 tunnel names through the I2CP SessionConfig. Use utf8 = false for RouterAddress (fast, non UTF-8) Use utf8 = true for SessionConfig (slow, UTF-8)
java.io.IOException

toProperties

public static int toProperties(byte[] target,
                               int offset,
                               java.util.Properties props)
                        throws DataFormatException,
                               java.io.IOException
Throws:
DataFormatException
java.io.IOException

fromProperties

public static int fromProperties(byte[] source,
                                 int offset,
                                 java.util.Properties target)
                          throws DataFormatException,
                                 java.io.IOException
Deprecated. unused

Reads the props from the byte array and puts them in the Properties target See readProperties() for the format. Warning - confusing method name, Properties is the target.

Parameters:
source - source
target - returned Properties
Returns:
new offset
Throws:
DataFormatException
java.io.IOException

toProperties

public static byte[] toProperties(java.util.Properties opts)
Deprecated. unused

Writes the props to returned byte array, not sorted (unless the opts param is an OrderedProperties) See readProperties() for the format. Property keys and values must not contain '=' or ';', this is not checked and they are not escaped Keys and values must be 255 bytes or less, Formatted length must not exceed 65535 bytes Warning - confusing method name, Properties is the source.

Throws:
java.lang.RuntimeException - if either is too long.

toString

public static java.lang.String toString(java.util.Properties options)
Pretty print the mapping, unsorted (unless the options param is an OrderedProperties)


loadProps

public static void loadProps(java.util.Properties props,
                             java.io.File file)
                      throws java.io.IOException
A more efficient Properties.load Some of the other differences: - This does not process or drop backslashes - '#' or ';' starts a comment line, but '!' does not - Leading whitespace is not trimmed - '=' is the only key-termination character (not ':' or whitespace) Note that the escaping of \r or \n was probably a mistake and should be taken out.

Throws:
java.io.IOException

loadProps

public static void loadProps(java.util.Properties props,
                             java.io.File file,
                             boolean forceLowerCase)
                      throws java.io.IOException
Throws:
java.io.IOException

loadProps

public static void loadProps(java.util.Properties props,
                             java.io.InputStream inStr)
                      throws java.io.IOException
Throws:
java.io.IOException

loadProps

public static void loadProps(java.util.Properties props,
                             java.io.InputStream inStr,
                             boolean forceLowerCase)
                      throws java.io.IOException
Throws:
java.io.IOException

storeProps

public static void storeProps(java.util.Properties props,
                              java.io.File file)
                       throws java.io.IOException
Writes the props to the file, unsorted (unless props is an OrderedProperties) Note that this does not escape the \r or \n that are unescaped in loadProps() above.

Throws:
java.io.IOException

toString

public static java.lang.String toString(java.util.Collection col)
Pretty print the collection


toString

public static java.lang.String toString(byte[] buf)

toString

public static java.lang.String toString(byte[] buf,
                                        int len)

toDecimalString

public static java.lang.String toDecimalString(byte[] buf,
                                               int len)

toHexString

public static final java.lang.String toHexString(byte[] data)

fromHexString

public static final byte[] fromHexString(java.lang.String val)

readLong

public static long readLong(java.io.InputStream rawStream,
                            int numBytes)
                     throws DataFormatException,
                            java.io.IOException
Read the stream for an integer as defined by the I2P data structure specification. Integers are a fixed number of bytes (numBytes), stored as unsigned integers in network byte order.

Parameters:
rawStream - stream to read from
numBytes - number of bytes to read and format into a number
Returns:
number
Throws:
DataFormatException - if the stream doesn't contain a validly formatted number of that many bytes
java.io.IOException - if there is an IO error reading the number

writeLong

public static void writeLong(java.io.OutputStream rawStream,
                             int numBytes,
                             long value)
                      throws DataFormatException,
                             java.io.IOException
Write an integer as defined by the I2P data structure specification to the stream. Integers are a fixed number of bytes (numBytes), stored as unsigned integers in network byte order.

Parameters:
value - value to write out
rawStream - stream to write to
numBytes - number of bytes to write the number into (padding as necessary)
Throws:
DataFormatException - if the stream doesn't contain a validly formatted number of that many bytes
java.io.IOException - if there is an IO error writing to the stream

toLong

public static byte[] toLong(int numBytes,
                            long value)
                     throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

toLong

public static void toLong(byte[] target,
                          int offset,
                          int numBytes,
                          long value)
                   throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

fromLong

public static long fromLong(byte[] src,
                            int offset,
                            int numBytes)

readDate

public static java.util.Date readDate(java.io.InputStream in)
                               throws DataFormatException,
                                      java.io.IOException
Read in a date from the stream as specified by the I2P data structure spec. A date is an 8 byte unsigned integer in network byte order specifying the number of milliseconds since midnight on January 1, 1970 in the GMT timezone. If the number is 0, the date is undefined or null. (yes, this means you can't represent midnight on 1/1/1970)

Parameters:
in - stream to read from
Returns:
date read, or null
Throws:
DataFormatException - if the stream doesn't contain a validly formatted date
java.io.IOException - if there is an IO error reading the date

writeDate

public static void writeDate(java.io.OutputStream out,
                             java.util.Date date)
                      throws DataFormatException,
                             java.io.IOException
Write out a date to the stream as specified by the I2P data structure spec.

Parameters:
out - stream to write to
date - date to write (can be null)
Throws:
DataFormatException - if the date is not valid
java.io.IOException - if there is an IO error writing the date

toDate

public static byte[] toDate(java.util.Date date)
                     throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

toDate

public static void toDate(byte[] target,
                          int offset,
                          long when)
                   throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

fromDate

public static java.util.Date fromDate(byte[] src,
                                      int offset)
                               throws DataFormatException
Throws:
DataFormatException

readString

public static java.lang.String readString(java.io.InputStream in)
                                   throws DataFormatException,
                                          java.io.IOException
Read in a string from the stream as specified by the I2P data structure spec. A string is 1 or more bytes where the first byte is the number of bytes (not characters!) in the string and the remaining 0-255 bytes are the non-null terminated UTF-8 encoded character array.

Parameters:
in - stream to read from
Returns:
UTF-8 string
Throws:
DataFormatException - if the stream doesn't contain a validly formatted string
java.io.IOException - if there is an IO error reading the string

writeString

public static void writeString(java.io.OutputStream out,
                               java.lang.String string)
                        throws DataFormatException,
                               java.io.IOException
Write out a string to the stream as specified by the I2P data structure spec. Note that the max size for a string allowed by the spec is 255 bytes. WARNING - this method destroys the encoding, and therefore violates the data structure spec.

Parameters:
out - stream to write string
string - string to write out: null strings are perfectly valid, but strings of excess length will cause a DataFormatException to be thrown
Throws:
DataFormatException - if the string is not valid
java.io.IOException - if there is an IO error writing the string

readBoolean

public static java.lang.Boolean readBoolean(java.io.InputStream in)
                                     throws DataFormatException,
                                            java.io.IOException
Deprecated. unused

Read in a boolean as specified by the I2P data structure spec. A boolean is 1 byte that is either 0 (false), 1 (true), or 2 (null)

Parameters:
in - stream to read from
Returns:
boolean value, or null
Throws:
DataFormatException - if the boolean is not valid
java.io.IOException - if there is an IO error reading the boolean

writeBoolean

public static void writeBoolean(java.io.OutputStream out,
                                java.lang.Boolean bool)
                         throws DataFormatException,
                                java.io.IOException
Deprecated. unused

Write out a boolean as specified by the I2P data structure spec. A boolean is 1 byte that is either 0 (false), 1 (true), or 2 (null)

Parameters:
out - stream to write to
bool - boolean value, or null
Throws:
DataFormatException - if the boolean is not valid
java.io.IOException - if there is an IO error writing the boolean

fromBoolean

public static java.lang.Boolean fromBoolean(byte[] data,
                                            int offset)
Deprecated. unused


toBoolean

public static void toBoolean(byte[] data,
                             int offset,
                             boolean value)
Deprecated. unused


toBoolean

public static void toBoolean(byte[] data,
                             int offset,
                             java.lang.Boolean value)
Deprecated. unused


eq

public static final boolean eq(java.lang.Object lhs,
                               java.lang.Object rhs)
Helper util to compare two objects, including null handling.

This treats (null == null) as true, and (null == (!null)) as false.


eq

public static final boolean eq(java.util.Collection lhs,
                               java.util.Collection rhs)
Run a deep comparison across the two collections.

This treats (null == null) as true, (null == (!null)) as false, and then comparing each element via eq(object, object).

If the size of the collections are not equal, the comparison returns false. The collection order should be consistent, as this simply iterates across both and compares based on the value of each at each step along the way.


eq

public static final boolean eq(byte[] lhs,
                               byte[] rhs)
Run a comparison on the byte arrays, byte by byte.

This treats (null == null) as true, (null == (!null)) as false, and unequal length arrays as false.


eq

public static final boolean eq(int lhs,
                               int rhs)
Deprecated. inefficient

Compare two integers, really just for consistency.


eq

public static final boolean eq(long lhs,
                               long rhs)
Deprecated. inefficient

Compare two longs, really just for consistency.


eq

public static final boolean eq(byte lhs,
                               byte rhs)
Deprecated. inefficient

Compare two bytes, really just for consistency.


eq

public static final boolean eq(byte[] lhs,
                               int offsetLeft,
                               byte[] rhs,
                               int offsetRight,
                               int length)

compareTo

public static final int compareTo(byte[] lhs,
                                  byte[] rhs)
treat bytes as unsigned


xor

public static final byte[] xor(byte[] lhs,
                               byte[] rhs)

xor

public static final void xor(byte[] lhs,
                             int startLeft,
                             byte[] rhs,
                             int startRight,
                             byte[] out,
                             int startOut,
                             int len)
xor the lhs with the rhs, storing the result in out.

Parameters:
lhs - one of the source arrays
startLeft - starting index in the lhs array to begin the xor
rhs - the other source array
startRight - starting index in the rhs array to begin the xor
out - output array
startOut - starting index in the out array to store the result
len - how many bytes into the various arrays to xor

hashCode

public static int hashCode(java.lang.Object obj)
Calculate the hashcode of the object, using 0 for null


hashCode

public static int hashCode(java.util.Date obj)
Calculate the hashcode of the date, using 0 for null


hashCode

public static int hashCode(byte[] b)
Calculate the hashcode of the byte array, using 0 for null


hashCode

public static int hashCode(java.util.Collection col)
Calculate the hashcode of the collection, using 0 for null


read

public static int read(java.io.InputStream in,
                       byte[] target)
                throws java.io.IOException
Throws:
java.io.IOException

read

public static int read(java.io.InputStream in,
                       byte[] target,
                       int offset,
                       int length)
                throws java.io.IOException
Throws:
java.io.IOException

readLine

public static java.lang.String readLine(java.io.InputStream in)
                                 throws java.io.IOException
Read a newline delimited line from the stream, returning the line (without the newline), or null if EOF reached before the newline was found Warning - strips \n but not \r Warning - 8KB line length limit as of 0.7.13, @throws IOException if exceeded

Throws:
java.io.IOException

readLine

public static java.lang.String readLine(java.io.InputStream in,
                                        Sha256Standalone hash)
                                 throws java.io.IOException
update the hash along the way Warning - strips \n but not \r Warning - 8KB line length limit as of 0.7.13, @throws IOException if exceeded

Throws:
java.io.IOException

readLine

public static boolean readLine(java.io.InputStream in,
                               java.lang.StringBuffer buf)
                        throws java.io.IOException
Deprecated. use StringBuilder version

Read in a line, placing it into the buffer (excluding the newline). Warning - strips \n but not \r Warning - 8KB line length limit as of 0.7.13, @throws IOException if exceeded

Returns:
true if the line was read, false if eof was reached before a newline was found
Throws:
java.io.IOException

readLine

public static boolean readLine(java.io.InputStream in,
                               java.lang.StringBuffer buf,
                               Sha256Standalone hash)
                        throws java.io.IOException
Deprecated. use StringBuilder version

update the hash along the way Warning - strips \n but not \r Warning - 8KB line length limit as of 0.7.13, @throws IOException if exceeded

Throws:
java.io.IOException

readLine

public static boolean readLine(java.io.InputStream in,
                               java.lang.StringBuilder buf)
                        throws java.io.IOException
Read in a line, placing it into the buffer (excluding the newline). Warning - strips \n but not \r Warning - 8KB line length limit as of 0.7.13, @throws IOException if exceeded

Returns:
true if the line was read, false if eof was reached before a newline was found
Throws:
java.io.IOException

readLine

public static boolean readLine(java.io.InputStream in,
                               java.lang.StringBuilder buf,
                               Sha256Standalone hash)
                        throws java.io.IOException
update the hash along the way Warning - strips \n but not \r Warning - 8KB line length limit as of 0.7.13, @throws IOException if exceeded

Throws:
java.io.IOException

write

public static void write(java.io.OutputStream out,
                         byte[] data,
                         Sha256Standalone hash)
                  throws java.io.IOException
Throws:
java.io.IOException

sortStructures

public static java.util.List<? extends DataStructure> sortStructures(java.util.Collection<? extends DataStructure> dataStructures)
Sort based on the Hash of the DataStructure Warning - relatively slow. Only used by RouterInfo Why? Just because it has to be consistent so signing will work? How to spec as returning the same type as the param?


formatDuration

public static java.lang.String formatDuration(long ms)

formatSize

public static java.lang.String formatSize(long bytes)
Caller should append 'B' or 'b' as appropriate


formatSize2

public static java.lang.String formatSize2(long bytes)
Like formatSize but with a space after the number

Since:
0.7.14

stripHTML

public static java.lang.String stripHTML(java.lang.String orig)
Strip out any HTML (simply removing any less than / greater than symbols)


compress

public static byte[] compress(byte[] orig)
compress the data and return a new GZIP compressed array


compress

public static byte[] compress(byte[] orig,
                              int offset,
                              int size)

compress

public static byte[] compress(byte[] orig,
                              int offset,
                              int size,
                              int level)

decompress

public static byte[] decompress(byte[] orig)
                         throws java.io.IOException
decompress the GZIP compressed data (returning null on error)

Throws:
java.io.IOException

decompress

public static byte[] decompress(byte[] orig,
                                int offset,
                                int length)
                         throws java.io.IOException
Throws:
java.io.IOException

getUTF8

public static byte[] getUTF8(java.lang.String orig)

getUTF8

public static byte[] getUTF8(java.lang.StringBuffer orig)

getUTF8

public static java.lang.String getUTF8(byte[] orig)

getUTF8

public static java.lang.String getUTF8(byte[] orig,
                                       int offset,
                                       int len)