public class Common extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
Common.ArrayBlockRef |
static class |
Common.Edge |
static class |
Common.StringToBoolean |
static class |
Common.StringToFloat |
static class |
Common.StringToInt |
static class |
Common.StringToLong |
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
DEFAULT_DATE_FORMAT |
static String |
DEFAULT_DATETIME_FORMAT |
static String |
DEFAULT_TIME_FORMAT |
static String |
FILE_SEPARATOR |
static String |
PATH_SEPARATOR |
static int |
PROCESSOR_COUNT |
static Long |
SYSTEM_START_TIME |
static String |
USER_DIR |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> Set<T> |
arrayToSet(T[] array) |
static byte[] |
base16Decode(String hexString) |
static byte[] |
base16Decode(String hexString,
String ignoreChars) |
static String |
base16Encode(byte[] b) |
static String |
base16Encode(byte[] b,
Function<Integer,Integer> colFunction,
String split) |
static String |
base16Encode(byte[] b,
int offset,
int length) |
static String |
base16Encode(byte[] b,
int offset,
int length,
Function<Integer,Integer> colFunction,
String split) |
static String |
base16Encode(byte[] b,
int offset,
int length,
int col,
String split) |
static String |
base16Encode(byte[] b,
int col,
String split) |
static <T extends Comparable<T>> |
between(T t,
T bound1,
T bound2)
|
static String |
byte2hex(byte[] b)
已过时。
|
static String |
byte2hex(byte[] b,
int offset,
int length)
已过时。
|
static String |
byte2hex(byte[] b,
int offset,
int length,
int col,
String split)
已过时。
|
static String |
byte2hex(byte[] b,
int col,
String split)
已过时。
|
static Calendar |
calendar(int year) |
static Calendar |
calendar(int year,
int month) |
static Calendar |
calendar(int year,
int month,
int date) |
static Calendar |
calendar(int year,
int month,
int date,
int hour) |
static Calendar |
calendar(int year,
int month,
int date,
int hour,
int minute) |
static Calendar |
calendar(int year,
int month,
int date,
int hour,
int minute,
int second) |
static Calendar |
calendar(int year,
int month,
int date,
int hour,
int minute,
int second,
int millisecond) |
static String |
calendarToStr(Calendar calendar) |
static String |
calendarToStr(Calendar calendar,
String format) |
static String |
camelCase(String s) |
static String |
camelCase(String s,
boolean firstCharUpperCase) |
static String |
camelCase(String s,
boolean firstCharUpperCase,
String delimiters) |
static String |
camelCase(String s,
String delimiters) |
static <T> T |
cast(Object obj) |
static void |
checkNull(Object o,
String msg)
已过时。
|
static String |
concat(Collection<String> list,
String split) |
static Calendar |
copy(Calendar calendar) |
static <K extends Serializable,V extends Serializable> |
copyMap(Map<K,V> org,
Map<K,V> target) |
static void |
copyStream(InputStream is,
OutputStream os) |
static void |
copyStream(InputStream is,
OutputStream os,
int blockSize,
boolean flushPerBlock,
int bps) |
static Calendar |
dateToCalendar(Date date) |
static String |
dateToStr(Date date) |
static String |
dateToStr(Date date,
String format) |
static <T extends Serializable> |
deepCopy(T object) |
static Object |
deserialize(byte[] buf) |
static <T> Set<T> |
difference(Set<T> org,
Set<T> todiv)
差集 org - todiv
|
static <T> int |
findInArray(T el,
T[] array)
|
static <T> void |
forEachBlock(T[] all,
int blockSize,
boolean continuous,
float redundancy,
BiConsumer<Integer,Integer> consumer)
对一个大数组进行分块操作
|
static <T> void |
forEachBlock(T[] all,
int blockSize,
boolean continuous,
float redundancy,
IntFunction<T[]> arrayProvider,
Consumer<T[]> consumer)
对一个大数组进行分块操作
|
static <T> String |
formatArray(T[] array,
int offset,
int length,
Function<Integer,Integer> colFunction,
String split,
Function<T,String> encoder) |
static File |
getNewFile(String fileName)
已过时。
|
static URL |
getResource(String resource,
ClassLoader... classLoaders) |
static DateFormat |
getSafetyDateFormat(String format) |
static Long |
getSystemStart() |
static String |
getUUIDStr()
已过时。
|
static byte[] |
hex2byte(String hexString)
已过时。
|
static byte[] |
hex2byte(String hexString,
String ignoreChars)
已过时。
|
static <T> boolean |
inArray(T el,
T[] array) |
static <T> int |
indexOf(T[] array,
T t) |
static <T> Set<T> |
intersection(Set<T> set1,
Set<T> set2)
交集
|
static boolean |
isBlank(String s) |
static boolean |
isDebug() |
static boolean |
isEmpty(Collection<?> collection) |
static boolean |
isJava9AndLast() |
static boolean |
isWindows() |
static <T> Set<T> |
join(Collection<T>... sets)
并集
|
static byte[] |
long2Bytes(long data) |
static Calendar |
longToCalendar(long l) |
static String |
longToDateStr(long l) |
static String |
longToDateStr(long l,
String format) |
static String |
lowerFirstChar(String string) |
static <T extends Comparable<T>> |
max(T c1,
T c2,
T... others) |
static <T extends Comparable<T>> |
min(T c1,
T c2,
T... others) |
static String |
native2AscII(String str) |
static File |
newFile(String fileName) |
static String |
now() |
static String |
now(String format) |
static String |
nullToStr(String str) |
static byte |
random(byte[] range) |
static double |
random(double[] range) |
static double |
random(double min,
double max) |
static float |
random(float[] range) |
static int |
random(int max) |
static int |
random(int[] range) |
static int |
random(int min,
int max) |
static long |
random(long max) |
static long |
random(long[] range) |
static long |
random(long min,
long max) |
static short |
random(short[] range) |
static <T> T |
random(T[] range) |
static int |
randomC(int max) |
static int |
randomC(int min,
int max) |
static long |
randomC(long max) |
static long |
randomC(long min,
long max) |
static char |
randomChar(String s) |
static char |
randomGB2312Char()
https://zh.wikipedia.org/wiki/GB_2312
|
static String |
randomStr(int min,
int max,
String range) |
static RuntimeException |
rte(Throwable th) |
static boolean |
sameString(String str1,
String str2)
已过时。
|
static byte[] |
serialize(Object object) |
static String |
sha1(String content) |
static String |
sha1(String content,
Charset charset) |
static double |
similarity(String s1,
String s2) |
static void |
sleep(long ms) |
static <T> Collection<Common.ArrayBlockRef> |
slice(T[] all,
int blockSize,
boolean continuous,
float redundancy)
将一个大数组分块
|
static Calendar |
strToCalendar(String str,
String format) |
static Date |
strToDate(String str) |
static Date |
strToDate(String str,
String format) |
static <T> Map<String,T> |
subMap(String prefix,
Map<String,T> map) |
static <T> T |
to(String str,
T value) |
static String |
toAbsolutePath(String path) |
static List<String> |
toArray(String str,
String delim,
List<String> v) |
static String[] |
toArray(String str,
String delim,
String[] v) |
static String[] |
toArray(String str,
String delim,
Supplier<String[]> v) |
static boolean |
toBool(String str,
boolean v) |
static boolean |
toBool(String str,
Supplier<Boolean> v) |
static byte[] |
toBytes(long l,
int wide,
Endianness endianness) |
static int |
toInt(String str,
int value) |
static int |
toInt(String str,
Supplier<Integer> valueSupplier) |
static long |
toLong(String str,
long value) |
static long |
toLong(String str,
Supplier<Long> value) |
static String |
trim(String str,
char... trimChars) |
static String |
trim(String str,
String toTrim) |
static Calendar |
truncate(Calendar calendar,
int fromField) |
static String |
upperFirstChar(String string) |
public static final String PATH_SEPARATOR
public static final String FILE_SEPARATOR
public static final String USER_DIR
public static final Long SYSTEM_START_TIME
public static final int PROCESSOR_COUNT
public static boolean isWindows()
public static boolean isDebug()
public static byte[] toBytes(long l,
int wide,
Endianness endianness)
public static <T> Set<T> arrayToSet(T[] array)
@Deprecated public static String getUUIDStr()
IDGenerator.newId()替代
获取uuid时,使用UUIDHelper.getUUIDString()
public static <T> boolean inArray(T el,
T[] array)
@Deprecated public static <T> int findInArray(T el, T[] array)
public static byte[] serialize(Object object) throws IOException
IOExceptionpublic static Object deserialize(byte[] buf) throws IOException, ClassNotFoundException
public static <T extends Serializable> T deepCopy(T object) throws IOException, ClassNotFoundException
public static int random(int max)
max - 正整数public static int randomC(int max)
max - 非负正数public static int random(int min,
int max)
public static int randomC(int min,
int max)
public static long random(long min,
long max)
public static long random(long max)
public static long randomC(long max)
public static long randomC(long min,
long max)
public static double random(double min,
double max)
public static <K extends Serializable,V extends Serializable> void copyMap(Map<K,V> org, Map<K,V> target)
public static boolean isBlank(String s)
public static boolean isEmpty(Collection<?> collection)
public static void copyStream(InputStream is, OutputStream os) throws IOException
IOExceptionpublic static void copyStream(InputStream is, OutputStream os, int blockSize, boolean flushPerBlock, int bps) throws IOException
IOException@Deprecated public static void checkNull(Object o, String msg)
Objects.requireNonNull(Object, String) 替代@Deprecated public static <T extends Comparable<T>> boolean between(T t, T bound1, T bound2)
@SafeVarargs public static <T extends Comparable<T>> T max(T c1, T c2, T... others)
@Deprecated public static String byte2hex(byte[] b)
@Deprecated public static String byte2hex(byte[] b, int offset, int length)
@Deprecated public static String byte2hex(byte[] b, int col, String split)
@Deprecated public static String byte2hex(byte[] b, int offset, int length, int col, String split)
public static String base16Encode(byte[] b)
b - 需要编码的字节数组public static String base16Encode(byte[] b, int offset, int length)
b - 需要编码的字节数组offset - 编码字节数组偏移length - 编码字节数组长度public static String base16Encode(byte[] b, int col, String split)
b - 需要编码的字节数组col - 每个字节编码后算一列,此参数用来指定编码后每行多少列,行与行之间使用系统变量line.separator来分隔split - 列于列之间的分隔字符传串,行首行尾不加public static String base16Encode(byte[] b, Function<Integer,Integer> colFunction, String split)
b - 需要编码的字节数组colFunction - 每个字节编码后算一列,此参数用来指定编码后各行多少列,行与行之间使用系统变量line.separator来分隔split - 列于列之间的分隔字符传串,行首行尾不加public static String base16Encode(byte[] b, int offset, int length, int col, String split)
b - 需要编码的字节数组offset - 编码字节数组偏移length - 编码字节数组长度col - 每个字节编码后算一列,此参数用来指定编码后每行多少列,行与行之间使用系统变量line.separator来分隔split - 列于列之间的分隔字符传串,行首行尾不加public static String base16Encode(byte[] b, int offset, int length, Function<Integer,Integer> colFunction, String split)
b - 需要编码的字节数组offset - 编码字节数组偏移length - 编码字节数组长度colFunction - 每个字节编码后算一列,此参数用来指定编码后各行多少列,行与行之间使用系统变量line.separator来分隔split - 列于列之间的分隔字符传串,行首行尾不加public static <T> String formatArray(T[] array, int offset, int length, Function<Integer,Integer> colFunction, String split, Function<T,String> encoder)
@Deprecated public static byte[] hex2byte(String hexString)
@Deprecated public static byte[] hex2byte(String hexString, String ignoreChars)
public static byte[] base16Decode(String hexString)
public static <T> Set<T> intersection(Set<T> set1, Set<T> set2)
set1 - set1set2 - set2public static <T> Set<T> difference(Set<T> org, Set<T> todiv)
org - orgtodiv - todiv@SafeVarargs public static <T> Set<T> join(Collection<T>... sets)
sets - sets@Deprecated public static File getNewFile(String fileName) throws IOException
IOExceptionpublic static File newFile(String fileName) throws IOException
IOExceptionpublic static URL getResource(String resource, ClassLoader... classLoaders)
public static <T> int indexOf(T[] array,
T t)
public static String concat(Collection<String> list, String split)
public static <T> T to(String str, T value)
public static int toInt(String str, int value)
public static long toLong(String str, long value)
public static boolean toBool(String str, boolean v)
@Deprecated public static boolean sameString(String str1, String str2)
public static char randomGB2312Char()
public static char randomChar(String s)
public static <T> T random(T[] range)
public static byte random(byte[] range)
public static short random(short[] range)
public static int random(int[] range)
public static long random(long[] range)
public static float random(float[] range)
public static double random(double[] range)
public static DateFormat getSafetyDateFormat(String format)
public static Date strToDate(String str, String format) throws ParseException
ParseExceptionpublic static Date strToDate(String str) throws ParseException
ParseExceptionpublic static Calendar strToCalendar(String str, String format) throws ParseException
ParseExceptionpublic static byte[] long2Bytes(long data)
public static String longToDateStr(long l)
public static Calendar longToCalendar(long l)
@SafeVarargs public static <T extends Comparable<T>> T min(T c1, T c2, T... others)
public static Calendar calendar(int year)
public static Calendar calendar(int year, int month)
public static Calendar calendar(int year, int month, int date)
public static Calendar calendar(int year, int month, int date, int hour)
public static Calendar calendar(int year, int month, int date, int hour, int minute)
public static Calendar calendar(int year, int month, int date, int hour, int minute, int second)
public static Calendar calendar(int year, int month, int date, int hour, int minute, int second, int millisecond)
public static String now()
public static RuntimeException rte(Throwable th)
public static Long getSystemStart()
public static <T> T cast(Object obj)
public static void sleep(long ms)
public static <T> void forEachBlock(T[] all,
int blockSize,
boolean continuous,
float redundancy,
BiConsumer<Integer,Integer> consumer)
T - 元素类型all - 所有的数据blockSize - 块大小continuous - 是否连续,[0,100),[100, last]为不连续,[0,100][100, last]为连续redundancy - 最后一块的冗余比例consumer - 每块数据如何处理public static <T> void forEachBlock(T[] all,
int blockSize,
boolean continuous,
float redundancy,
IntFunction<T[]> arrayProvider,
Consumer<T[]> consumer)
T - Tall - 所有元素blockSize - 块大小continuous - 是否连续,[0,100),[100, last]为不连续,[0,100][100, last]为连续redundancy - 最后一块的冗余比例arrayProvider - 新数组如何创建consumer - 数组处理逻辑public static <T> Collection<Common.ArrayBlockRef> slice(T[] all, int blockSize, boolean continuous, float redundancy)
T - Tall - 大数组blockSize - 块大小continuous - 是否连续,[0,100),[100, last]为不连续,[0,100][100, last]为连续redundancy - 最后一块的冗余比例public static boolean isJava9AndLast()
Copyright © 2022. All rights reserved.