Class Util

java.lang.Object
io.milton.zsync.Util

public final class Util extends Object
A number of useful, static methods.
Version:
$Revision: 1.7 $
  • Field Details

  • Method Details

    • base64

      public static 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.
      Throws:
      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.
    • close

      public static void close(RandomAccessFile randAccess)
    • close

      public static void close(FileChannel rc)