Class Util
- java.lang.Object
-
- de.akquinet.jbosscc.guttenbase.utils.Util
-
public abstract class Util extends Object
Collection of utility methods.© 2012-2034 akquinet tech@spree
- Author:
- M. Dahm
-
-
Field Summary
Fields Modifier and Type Field Description static Class<?>ByteArrayClassstatic intDEFAULT_BUFFER_SIZE
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcopy(InputStream input, OutputStream output)static <T> TcopyObject(Class<T> clazz, T sourceObject)Create deep copy of object.static voiddeleteDirectory(File directory)static StringformatTime(long millis)static <T> TfromByteArray(Class<T> clazz, byte[] byteArray)Deserialize from byte arraystatic <T> TfromInputStream(Class<T> clazz, InputStream inputStream)Deserialize from input streamstatic InputStreamgetResourceAsStream(String resource)static StringgetStringFromStream(InputStream inputStream)static booleanisWindows()static List<String>parseSelectedColumns(String sql)static List<String>readLinesFromFile(String resourceName, String encoding)Read all non-empty lines for File and remove and trim them.static List<String>readLinesFromStream(InputStream inputStream, String encoding)Read all non-empty lines and remove and trim them.static byte[]toByteArray(Object sourceObject)Serialize into byte arraystatic Stringtrim(String src)
-
-
-
Field Detail
-
ByteArrayClass
public static final Class<?> ByteArrayClass
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
-
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.
-
toByteArray
public static byte[] toByteArray(Object sourceObject) throws IOException
Serialize into byte array- Throws:
IOException
-
fromByteArray
public static <T> T fromByteArray(Class<T> clazz, byte[] byteArray) throws Exception
Deserialize from byte array- Throws:
Exception
-
fromInputStream
public static <T> T fromInputStream(Class<T> clazz, InputStream inputStream) throws Exception
Deserialize from input stream- Throws:
Exception
-
copy
public static void copy(InputStream input, OutputStream output) throws IOException
- Throws:
IOException
-
formatTime
public static String formatTime(long millis)
-
deleteDirectory
public static void deleteDirectory(File directory)
-
getStringFromStream
public static String getStringFromStream(InputStream inputStream) throws IOException
- Throws:
IOException
-
isWindows
public static boolean isWindows()
-
-