Skip to main content

CommonUtils-通用工具类

作用​

本工具类主要提供不太好分类的通用工具方法。

API列表​

/**
* 复制对象属性的方法
*
* @param source 源对象
* @param target 目标对象
* @param ignoreNullValue 是否忽略空值(true:是,false:不是)
*/
public static void copyProperties(Object source, Object target, boolean ignoreNullValue) {
// to do sth.
}
/**
* 获取当前进程ID的方法
*
* @return 返回当前进程ID
*/
public static String getPid() {
// to do sth.
}
/**
* <p>字符串快速分割。</p>
*
* <p>
* 提供更高效简洁的分割算法,在相同情况下,分割效率约为<br />
* {@link String#split(String)}的4倍<br />
* 但仅支持单个字符作为分割符。
* </p>
*
* <p>
* 当待分割字符串为null或者空串时,返回长度为0的数组<br />
* 该方法不会抛出任何异常
* </p>
*
* @param source 待分割字符串
* @param splitChar 分隔符
* @return 分割完毕的字符串数组
*/
public static String[] split(final String source, final char splitChar) {
// to do sth.
}
/**
* <p>字符串快速分割。</p>
*
* <p>
* 提供更高效简洁的分割算法,在相同情况下,分割效率约为<br />
* {@link String#split(String)}的4倍<br />
* 支持字符串作为分割符。
* </p>
*
* <p>
* 当待分割字符串为null或者空串时,返回长度为0的数组<br />
* 该方法不会抛出任何异常<br />
* 如果传入的字符串中仅含有1个字符,那么该方法会被转交给{@link #split(String, char)}处理
* </p>
*
* @param source 待分割字符串
* @param splitStr 分隔符字符串
* @return 分割完毕的字符串数组
* @see #split(String, char)
*/
public static String[] split(final String source, final String splitStr) {
// to do sth.
}

用法​

静态工具类方法,直接使用即可。

演示​

System.out.println(CommonUtils.getPid());