Class Util


  • public abstract class Util
    extends Object
    Collection of utility methods.

    © 2012-2034 akquinet tech@spree

    Author:
    M. Dahm
    • Field Detail

      • ByteArrayClass

        public static final Class<?> ByteArrayClass
    • Constructor Detail

      • Util

        public Util()
    • Method Detail

      • readLinesFromFile

        public static List<String> readLinesFromFile​(String resourceName,
                                                     String encoding)
        Read all non-empty lines for File and remove and trim them.
        Parameters:
        resourceName - Text file in CLASSPATH
        Returns:
        array of strings
      • getResourceAsStream

        public static InputStream getResourceAsStream​(String resource)
      • readLinesFromStream

        public static List<String> readLinesFromStream​(InputStream inputStream,
                                                       String encoding)
        Read all non-empty lines and remove and trim them.
        Parameters:
        inputStream - UTF8-encoded stream to read data from
        Returns:
        list of strings
      • copyObject

        public static <T> T copyObject​(Class<T> clazz,
                                       T sourceObject)
        Create deep copy of object.
      • fromByteArray

        public static <T> T fromByteArray​(Class<T> clazz,
                                          byte[] byteArray)
                                   throws Exception
        Deserialize from byte array
        Throws:
        Exception
      • formatTime

        public static String formatTime​(long millis)
      • deleteDirectory

        public static void deleteDirectory​(File directory)
      • isWindows

        public static boolean isWindows()
      • parseSelectedColumns

        public static List<String> parseSelectedColumns​(String sql)
        Returns:
        uppercased list of columns in SELECT statement