public class Util extends Object
| Constructor and Description |
|---|
Util() |
| Modifier and Type | Method and Description |
|---|---|
static <K> List<K> |
addTo(List<K> s,
K k) |
static <K> Set<K> |
addTo(Set<K> s,
K k) |
static void |
closeSilently(Closeable out) |
static void |
closeSilently(Connection c) |
static void |
closeSilently(InputStream in) |
static void |
closeSilently(OutputStream out) |
static void |
closeSilently(PreparedStatement c) |
static void |
closeSilently(Reader in) |
static void |
closeSilently(ResultSet c) |
static void |
closeSilently(ZipFile zip) |
static String |
commonPrefix(String s1,
String s2) |
static int |
compare(int x,
int y)
return sign of x - y
|
static int |
compare(long x,
long y)
return sign of x - y
|
static <T> Set<T> |
emptyOrNonnullSingleton(T t) |
static <E> E |
first(Iterable<E> i) |
static String |
getFileExtension(File f) |
static String |
getFileExtensionIgnoringGz(File f) |
static Reader |
getFileReader(File filename) |
static Reader |
getFileReader(String filename) |
static Writer |
getFileWriter(String filename) |
static MessageDigest |
getMD5Digest() |
static String |
getNetworkErrorMessage(Throwable e) |
static Reader |
getReader(InputStream in) |
static Writer |
getWriter(OutputStream out) |
static String |
getXMLType(InputStream in) |
static <K,V> Map<K,V> |
immutableMap(Map<K,V> map) |
static boolean |
isPowerOfTwo(int i) |
static boolean |
isPowerOfTwo(long i) |
static IOException |
makeIOException(String msg,
Throwable cause) |
static <K> ArrayList<K> |
makeSmallArrayList(List<K> m) |
static <K,V> HashMap<K,V> |
makeSmallHashMap(Map<K,V> m) |
static <K> HashSet<K> |
makeSmallHashSet(Collection<K> m) |
static <E> Set<E> |
newSetFromMap(Map<E,Boolean> m)
Duplication 1.6 functionality of Collections.newSetFromMap
|
static <T extends Comparable<? super T>> |
nullSafeCompareTo(T o1,
T o2) |
static <T> boolean |
nullSafeEquals(T o1,
T o2) |
static int |
nullSafeHashcode(Object o) |
static String |
repeat(String s,
int number) |
static Thread |
runInDameonThread(Runnable r) |
static Thread |
runInDameonThread(Runnable r,
String name) |
static void |
runLogAtShutdown(Runnable r) |
static Iterable<Integer> |
setBitIteratable(BitSet b) |
static Iterator<Integer> |
setBitIterator(BitSet b) |
static int |
sign(int x) |
static Thread |
startDameonThread(Thread t) |
static void |
throwIOException(String msg,
Throwable cause) |
public static int sign(int x)
public static int compare(int x,
int y)
public static int compare(long x,
long y)
public static void runLogAtShutdown(Runnable r)
public static <T> Set<T> emptyOrNonnullSingleton(T t)
public static int nullSafeHashcode(@CheckForNull Object o)
public static <T> boolean nullSafeEquals(@CheckForNull T o1, @CheckForNull T o2)
public static <T extends Comparable<? super T>> int nullSafeCompareTo(@CheckForNull T o1, @CheckForNull T o2)
public static Reader getReader(@WillCloseWhenClosed InputStream in)
public static Reader getFileReader(String filename) throws FileNotFoundException
FileNotFoundExceptionpublic static Reader getFileReader(File filename) throws FileNotFoundException
FileNotFoundExceptionpublic static Writer getWriter(@WillCloseWhenClosed OutputStream out)
public static Writer getFileWriter(String filename) throws FileNotFoundException
FileNotFoundExceptionpublic static void closeSilently(@WillClose Connection c)
public static void closeSilently(@WillClose PreparedStatement c)
public static void closeSilently(@WillClose ResultSet c)
public static void closeSilently(@WillClose InputStream in)
public static void closeSilently(@WillClose Reader in)
public static void closeSilently(@WillClose OutputStream out)
public static void closeSilently(@WillClose Closeable out)
public static void closeSilently(@WillClose ZipFile zip)
public static String getXMLType(@WillNotClose InputStream in) throws IOException
IOExceptionpublic static IOException makeIOException(String msg, Throwable cause)
public static void throwIOException(String msg, Throwable cause) throws IOException
IOExceptionpublic static <E> E first(Iterable<E> i)
i - the Iterable whose first element is to be retrievedpublic static <E> Set<E> newSetFromMap(Map<E,Boolean> m)
public static <K> HashSet<K> makeSmallHashSet(Collection<K> m)
@Nonnull public static MessageDigest getMD5Digest()
public static boolean isPowerOfTwo(int i)
public static boolean isPowerOfTwo(long i)
Copyright © 2003–2015. All rights reserved.