org.metastatic.rsync
Class Util

java.lang.Object
  |
  +--org.metastatic.rsync.Util

public final class Util
extends Object

A number of useful, static methods.


Field Summary
static String BASE_64
          The characters for Base64 encoding.
 
Method Summary
static String base64(byte[] buf)
          Base-64 encode a byte array, returning the returning string.
static String readLine(InputStream in)
          Read up to a '\n' or '\r', and return the resulting string.
static String toHexString(byte[] b)
          Convert a byte array to a big-endian ordered hexadecimal string.
static String toHexString(byte[] b, int off, int len)
          Convert a byte array to a big-endian ordered hexadecimal string.
static void writeASCII(OutputStream out, String ascii)
          Write a String as a sequece of ASCII bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE_64

public static final String BASE_64
The characters for Base64 encoding.

See Also:
Constant Field Values
Method Detail

base64

public static final String base64(byte[] buf)
Base-64 encode a byte array, returning the returning string.

Note that this method exists merely to be compatible with the challenge-response authentication method of rsyncd. It is not technincally a Base-64 encoder.

Parameters:
buf - The byte array to encode.
Returns:
buf encoded in Base64.

writeASCII

public static void writeASCII(OutputStream out,
                              String ascii)
                       throws IOException
Write a String as a sequece of ASCII bytes.

Parameters:
out - The OutputStream to write to.
ascii - The ASCII string to write.
Throws:
IOException - If writing fails.

readLine

public static String readLine(InputStream in)
                       throws IOException
Read up to a '\n' or '\r', and return the resulting string. The input is assumed to be ISO-8859-1.

Parameters:
in - The InputStream to read from.
Returns:
The line read, without the line terminator.
IOException

toHexString

public static String toHexString(byte[] b)
Convert a byte array to a big-endian ordered hexadecimal string.

Parameters:
b - The bytes to convert.
Returns:
A hexadecimal representation to b.

toHexString

public static String toHexString(byte[] b,
                                 int off,
                                 int len)
Convert a byte array to a big-endian ordered hexadecimal string.

Parameters:
b - The bytes to convert.
Returns:
A hexadecimal representation to b.