Package com.alibaba.druid.util
Class Utils
- java.lang.Object
-
- com.alibaba.druid.util.Utils
-
public class Utils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_BUFFER_SIZE
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longcopy(InputStream input, OutputStream output)static booleanequals(Object a, Object b)static longfnv_32_lower(String key)static longfnv_64(String input)static longfnv_64_lower(String key)static BooleangetBoolean(Properties properties, String key)static <T> TgetIfNull(T object, T defaultValue)Returns a default value if the object passed isnull.static IntegergetInteger(Properties properties, String key)static LonggetLong(Properties properties, String key)static StringgetStackTrace(Throwable ex)static DategetStartTime()static Stringhex(int hash)static Stringhex(long hash)static Stringhex_t(long hash)static Class<?>loadClass(String className)static voidloadFromFile(String path, Set<String> set)static PropertiesloadProperties(String resource)static Stringmd5(String text)static byte[]md5Bytes(String text)static longmurmurhash2_64(byte[] data, int length, int seed)murmur hash 2.0, The murmur hash is a relatively fast hash function from http://murmurhash.googlepages.com/ for platforms with efficient multiplication.static longmurmurhash2_64(String text)static voidputLong(byte[] b, int off, long val)static Stringread(InputStream in)static Stringread(Reader reader)static Stringread(Reader reader, int length)static byte[]readByteArray(InputStream input)static byte[]readByteArrayFromResource(String resource)static StringreadFromResource(String resource)static List<String>readLines(String resource)static StringtoString(StackTraceElement[] stackTrace)static StringtoString(Date date)
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
read
public static String read(InputStream in)
-
loadProperties
public static Properties loadProperties(String resource)
-
readFromResource
public static String readFromResource(String resource) throws IOException
- Throws:
IOException
-
readByteArrayFromResource
public static byte[] readByteArrayFromResource(String resource) throws IOException
- Throws:
IOException
-
readByteArray
public static byte[] readByteArray(InputStream input) throws IOException
- Throws:
IOException
-
copy
public static long copy(InputStream input, OutputStream output) throws IOException
- Throws:
IOException
-
toString
public static String toString(StackTraceElement[] stackTrace)
-
getBoolean
public static Boolean getBoolean(Properties properties, String key)
-
getInteger
public static Integer getInteger(Properties properties, String key)
-
getLong
public static Long getLong(Properties properties, String key)
-
getStartTime
public static final Date getStartTime()
-
murmurhash2_64
public static long murmurhash2_64(String text)
-
murmurhash2_64
public static long murmurhash2_64(byte[] data, int length, int seed)murmur hash 2.0, The murmur hash is a relatively fast hash function from http://murmurhash.googlepages.com/ for platforms with efficient multiplication.
-
md5Bytes
public static byte[] md5Bytes(String text)
-
putLong
public static void putLong(byte[] b, int off, long val)
-
hex
public static String hex(int hash)
-
hex
public static String hex(long hash)
-
hex_t
public static String hex_t(long hash)
-
fnv_64
public static long fnv_64(String input)
-
fnv_64_lower
public static long fnv_64_lower(String key)
-
fnv_32_lower
public static long fnv_32_lower(String key)
-
getIfNull
public static <T> T getIfNull(T object, T defaultValue)Returns a default value if the object passed isnull.
-
-