Class Utils


  • public class Utils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Utils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] base64decode​(java.lang.String string)
      Converts a Base-64 encoded string into a byte array.
      static java.lang.String base64encode​(byte[] bytes, boolean chunked)
      Converts a byte array into a Base-64 encoded string.
      static java.lang.String base64encodeMultiLine​(byte[] bytes)
      Converts a byte array into a multi-line Base-64 encoded string.
      static java.lang.String base64encodeSingleLine​(byte[] bytes)
      Converts a byte array into a single-line Base-64 encoded string.
      static boolean byteArraysAreEqual​(byte[] a, byte[] b)
      compares contents two byte arrays returning true if exactly same.
      static void checkHost​(java.lang.String hostname)  
      static void copy​(java.lang.String orig, java.lang.String dest)  
      static void copyStream​(java.io.BufferedReader in, java.io.OutputStreamWriter out)  
      static void copyStream​(java.io.InputStream in, java.io.OutputStream out)  
      static boolean exec​(java.lang.String cmd)  
      static java.lang.String[] getStringArrayFromVector​(java.util.Vector<java.lang.String> v)
      returns an array of strings from a vector of Strings there'll be trouble if the Vector contains something other than just Strings
      static boolean isNT()
      Checks if this is NT.
      static boolean isUnix()  
      static java.lang.String lsDateStr​(java.util.Date date)  
      static java.lang.String normalizeString​(java.lang.String string)
      Normalize B64 input String
      static java.lang.String normalizeString​(java.lang.String string, java.lang.Boolean keepSpace)  
      static void sortStrings​(java.lang.String[] strings)  
      static byte[] SpecialDecode​(java.lang.String s)  
      static java.lang.String SpecialEncode​(byte[] data)  
      static java.lang.String SpecialURLDecode​(java.lang.String s)  
      static java.lang.String stripQuotes​(java.lang.String s)
      strips out double quotes around String parameter
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Utils

        public Utils()
    • Method Detail

      • isNT

        public static boolean isNT()
        Checks if this is NT.
      • isUnix

        public static boolean isUnix()
      • exec

        public static boolean exec​(java.lang.String cmd)
      • SpecialURLDecode

        public static java.lang.String SpecialURLDecode​(java.lang.String s)
      • SpecialDecode

        public static byte[] SpecialDecode​(java.lang.String s)
      • SpecialEncode

        public static java.lang.String SpecialEncode​(byte[] data)
      • checkHost

        public static void checkHost​(java.lang.String hostname)
                              throws java.net.UnknownHostException
        Throws:
        java.net.UnknownHostException
      • copy

        public static void copy​(java.lang.String orig,
                                java.lang.String dest)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • copyStream

        public static void copyStream​(java.io.InputStream in,
                                      java.io.OutputStream out)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • copyStream

        public static void copyStream​(java.io.BufferedReader in,
                                      java.io.OutputStreamWriter out)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • sortStrings

        public static void sortStrings​(java.lang.String[] strings)
      • lsDateStr

        public static java.lang.String lsDateStr​(java.util.Date date)
      • byteArraysAreEqual

        public static boolean byteArraysAreEqual​(byte[] a,
                                                 byte[] b)
        compares contents two byte arrays returning true if exactly same.
      • stripQuotes

        public static java.lang.String stripQuotes​(java.lang.String s)
        strips out double quotes around String parameter
        Parameters:
        s - the string potentially bracketed with double quotes
        Returns:
        string stripped of surrounding double quotes
      • getStringArrayFromVector

        public static java.lang.String[] getStringArrayFromVector​(java.util.Vector<java.lang.String> v)
        returns an array of strings from a vector of Strings there'll be trouble if the Vector contains something other than just Strings
      • base64encode

        public static java.lang.String base64encode​(byte[] bytes,
                                                    boolean chunked)
        Converts a byte array into a Base-64 encoded string. If the chunked option is true, the output will be split into multiple lines. Otherwise, the output will be a single line.
        Parameters:
        bytes - byte array
        chunked - generate chunked output
        Returns:
        base-64 encoded data
      • base64encodeMultiLine

        public static java.lang.String base64encodeMultiLine​(byte[] bytes)
        Converts a byte array into a multi-line Base-64 encoded string. Each line is at most 64-character long and terminated with CRLF.
        Parameters:
        bytes - byte array
        Returns:
        base-64 encoded data
      • base64encodeSingleLine

        public static java.lang.String base64encodeSingleLine​(byte[] bytes)
        Converts a byte array into a single-line Base-64 encoded string. The line is not terminated with CRLF.
        Parameters:
        bytes - byte array
        Returns:
        base-64 encoded data
      • base64decode

        public static byte[] base64decode​(java.lang.String string)
        Converts a Base-64 encoded string into a byte array.
        Parameters:
        string - base-64 encoded data
        Returns:
        byte array
      • normalizeString

        public static java.lang.String normalizeString​(java.lang.String string)
        Normalize B64 input String
        Parameters:
        string - base-64 string
        keepspace - a boolean variable to control whether to keep spaces or not
        Returns:
        normalized string
      • normalizeString

        public static java.lang.String normalizeString​(java.lang.String string,
                                                       java.lang.Boolean keepSpace)