mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-24 18:04:54 +08:00
fix code
This commit is contained in:
parent
c753a53173
commit
67a0f31dd9
@ -1,9 +1,8 @@
|
||||
package cn.hutool.core.util;
|
||||
package cn.hutool.core.classloader;
|
||||
|
||||
import cn.hutool.core.convert.BasicType;
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.JarClassLoader;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import cn.hutool.core.map.WeakConcurrentMap;
|
||||
import cn.hutool.core.text.CharPool;
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.core.lang;
|
||||
package cn.hutool.core.classloader;
|
||||
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.io.FileUtil;
|
@ -1,7 +1,6 @@
|
||||
package cn.hutool.core.lang;
|
||||
package cn.hutool.core.classloader;
|
||||
|
||||
import cn.hutool.core.io.resource.Resource;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
|
||||
import java.security.SecureClassLoader;
|
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* 类加载相关封装和工具
|
||||
*
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
package cn.hutool.core.classloader;
|
@ -1,8 +1,8 @@
|
||||
package cn.hutool.core.compiler;
|
||||
|
||||
import cn.hutool.core.io.resource.FileObjectResource;
|
||||
import cn.hutool.core.lang.ResourceClassLoader;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ResourceClassLoader;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
|
||||
import javax.tools.FileObject;
|
||||
|
@ -9,7 +9,7 @@ import cn.hutool.core.io.resource.StringResource;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.net.URLUtil;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.hutool.core.convert.impl;
|
||||
|
||||
import cn.hutool.core.convert.AbstractConverter;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
|
||||
/**
|
||||
* 类转换器<br>
|
||||
|
@ -7,7 +7,7 @@ import cn.hutool.core.date.format.GlobalCustomFormat;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.core.util.SystemPropsUtil;
|
||||
import cn.hutool.core.util.SystemUtil;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.DateFormat;
|
||||
@ -311,7 +311,7 @@ public class DateTime extends Date {
|
||||
* @see DatePattern
|
||||
*/
|
||||
public DateTime(CharSequence dateStr, DateParser dateParser) {
|
||||
this(dateStr, dateParser, SystemPropsUtil.getBoolean(SystemPropsUtil.HUTOOL_DATE_LENIENT, true));
|
||||
this(dateStr, dateParser, SystemUtil.getBoolean(SystemUtil.HUTOOL_DATE_LENIENT, true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@ import cn.hutool.core.collection.IterUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.core.net.URLUtil;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.hutool.core.io.resource;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.reflect.ReflectUtil;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.hutool.core.lang;
|
||||
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.EnumerationIter;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
|
@ -14,6 +14,8 @@ import java.net.MalformedURLException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static cn.hutool.core.regex.PatternPool.*;
|
||||
|
||||
/**
|
||||
* 字段验证器(验证器),分两种类型的验证:
|
||||
*
|
||||
@ -28,85 +30,6 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class Validator {
|
||||
|
||||
/**
|
||||
* 英文字母 、数字和下划线
|
||||
*/
|
||||
public final static Pattern GENERAL = PatternPool.GENERAL;
|
||||
/**
|
||||
* 数字
|
||||
*/
|
||||
public final static Pattern NUMBERS = PatternPool.NUMBERS;
|
||||
/**
|
||||
* 分组
|
||||
*/
|
||||
public final static Pattern GROUP_VAR = PatternPool.GROUP_VAR;
|
||||
/**
|
||||
* IP v4
|
||||
*/
|
||||
public final static Pattern IPV4 = PatternPool.IPV4;
|
||||
/**
|
||||
* IP v6
|
||||
*/
|
||||
public final static Pattern IPV6 = PatternPool.IPV6;
|
||||
/**
|
||||
* 货币
|
||||
*/
|
||||
public final static Pattern MONEY = PatternPool.MONEY;
|
||||
/**
|
||||
* 邮件
|
||||
*/
|
||||
public final static Pattern EMAIL = PatternPool.EMAIL;
|
||||
/**
|
||||
* 移动电话
|
||||
*/
|
||||
public final static Pattern MOBILE = PatternPool.MOBILE;
|
||||
|
||||
/**
|
||||
* 身份证号码
|
||||
*/
|
||||
public final static Pattern CITIZEN_ID = PatternPool.CITIZEN_ID;
|
||||
|
||||
/**
|
||||
* 邮编
|
||||
*/
|
||||
public final static Pattern ZIP_CODE = PatternPool.ZIP_CODE;
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
public final static Pattern BIRTHDAY = PatternPool.BIRTHDAY;
|
||||
/**
|
||||
* URL
|
||||
*/
|
||||
public final static Pattern URL = PatternPool.URL;
|
||||
/**
|
||||
* Http URL
|
||||
*/
|
||||
public final static Pattern URL_HTTP = PatternPool.URL_HTTP;
|
||||
/**
|
||||
* 中文字、英文字母、数字和下划线
|
||||
*/
|
||||
public final static Pattern GENERAL_WITH_CHINESE = PatternPool.GENERAL_WITH_CHINESE;
|
||||
/**
|
||||
* UUID
|
||||
*/
|
||||
public final static Pattern UUID = PatternPool.UUID;
|
||||
/**
|
||||
* 不带横线的UUID
|
||||
*/
|
||||
public final static Pattern UUID_SIMPLE = PatternPool.UUID_SIMPLE;
|
||||
/**
|
||||
* 中国车牌号码
|
||||
*/
|
||||
public final static Pattern PLATE_NUMBER = PatternPool.PLATE_NUMBER;
|
||||
/**
|
||||
* 车架号;别名:车辆识别代号 车辆识别码;十七位码
|
||||
*/
|
||||
public final static Pattern CAR_VIN = PatternPool.CAR_VIN;
|
||||
/**
|
||||
* 驾驶证 别名:驾驶证档案编号、行驶证编号;12位数字字符串;仅限:中国驾驶证档案编号
|
||||
*/
|
||||
public final static Pattern CAR_DRIVING_LICENCE = PatternPool.CAR_DRIVING_LICENCE;
|
||||
|
||||
/**
|
||||
* 给定值是否为{@code true}
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.hutool.core.lang.id;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.RuntimeUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
@ -4,7 +4,7 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.getter.OptNullBasicTypeFromObjectGetter;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -8,7 +8,7 @@ import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.net.url.UrlQuery;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@ -205,7 +205,7 @@ public class ByteUtil {
|
||||
/**
|
||||
* long转byte数组<br>
|
||||
* 默认以小端序转换<br>
|
||||
* from: https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java
|
||||
* from: <a href="https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java">https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java</a>
|
||||
*
|
||||
* @param longValue long值
|
||||
* @return byte数组
|
||||
@ -217,7 +217,7 @@ public class ByteUtil {
|
||||
/**
|
||||
* long转byte数组<br>
|
||||
* 自定义端序<br>
|
||||
* from: https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java
|
||||
* from: <a href="https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java">https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java</a>
|
||||
*
|
||||
* @param longValue long值
|
||||
* @param byteOrder 端序
|
||||
@ -242,7 +242,7 @@ public class ByteUtil {
|
||||
/**
|
||||
* byte数组转long<br>
|
||||
* 默认以小端序转换<br>
|
||||
* from: https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java
|
||||
* from: <a href="https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java">https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java</a>
|
||||
*
|
||||
* @param bytes byte数组
|
||||
* @return long值
|
||||
@ -254,7 +254,7 @@ public class ByteUtil {
|
||||
/**
|
||||
* byte数组转long<br>
|
||||
* 自定义端序<br>
|
||||
* from: https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java
|
||||
* from: <a href="https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java">https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java</a>
|
||||
*
|
||||
* @param bytes byte数组
|
||||
* @param byteOrder 端序
|
||||
@ -267,7 +267,7 @@ public class ByteUtil {
|
||||
/**
|
||||
* byte数组转long<br>
|
||||
* 自定义端序<br>
|
||||
* from: https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java
|
||||
* from: <a href="https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java">https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java</a>
|
||||
*
|
||||
* @param bytes byte数组
|
||||
* @param start 计算数组开始位置
|
||||
@ -354,7 +354,7 @@ public class ByteUtil {
|
||||
/**
|
||||
* double转byte数组<br>
|
||||
* 自定义端序<br>
|
||||
* from: https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java
|
||||
* from: <a href="https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java">https://stackoverflow.com/questions/4485128/how-do-i-convert-long-to-byte-and-back-in-java</a>
|
||||
*
|
||||
* @param doubleValue double值
|
||||
* @param byteOrder 端序
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import cn.hutool.core.bean.NullWrapperBean;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.convert.BasicType;
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
@ -17,7 +17,7 @@ import java.util.Properties;
|
||||
* @author looly
|
||||
* @since 5.7.16
|
||||
*/
|
||||
public class SystemPropsUtil {
|
||||
public class SystemUtil {
|
||||
|
||||
/** Hutool自定义系统属性:是否解析日期字符串采用严格模式 */
|
||||
public static String HUTOOL_DATE_LENIENT = "hutool.date.lenient";
|
@ -243,8 +243,8 @@ public class ValidatorTest {
|
||||
String content = "https://detail.tmall.com/item.htm?" +
|
||||
"id=639428931841&ali_refid=a3_430582_1006:1152464078:N:Sk5vwkMVsn5O6DcnvicELrFucL21A32m:0af8611e23c1d07697e";
|
||||
|
||||
Assert.assertTrue(Validator.isMatchRegex(Validator.URL, content));
|
||||
Assert.assertTrue(Validator.isMatchRegex(Validator.URL_HTTP, content));
|
||||
Assert.assertTrue(Validator.isMatchRegex(PatternPool.URL, content));
|
||||
Assert.assertTrue(Validator.isMatchRegex(PatternPool.URL_HTTP, content));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -2,7 +2,7 @@ package cn.hutool.core.lang.reflect;
|
||||
|
||||
import cn.hutool.core.reflect.MethodHandleUtil;
|
||||
import cn.hutool.core.reflect.ReflectUtil;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -1,15 +1,16 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ClassLoaderUtilTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void loadClassTest() {
|
||||
String name = ClassLoaderUtil.loadClass("java.lang.Thread.State").getName();
|
||||
Assert.assertEquals("java.lang.Thread$State", name);
|
||||
|
||||
|
||||
name = ClassLoaderUtil.loadClass("java.lang.Thread$State").getName();
|
||||
Assert.assertEquals("java.lang.Thread$State", name);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.hutool.cron.task;
|
||||
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.util.ClassUtil;
|
||||
import cn.hutool.core.reflect.ReflectUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.hutool.db.dialect;
|
||||
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
import cn.hutool.core.regex.ReUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.db.dialect.impl.AnsiSqlDialect;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.extra.system;
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
import cn.hutool.core.net.NetUtil;
|
||||
|
||||
@ -60,8 +60,8 @@ public class HostInfo implements Serializable {
|
||||
public final String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
SystemUtil.append(builder, "Host Name: ", getName());
|
||||
SystemUtil.append(builder, "Host Address: ", getAddress());
|
||||
ManagementUtil.append(builder, "Host Name: ", getName());
|
||||
ManagementUtil.append(builder, "Host Address: ", getAddress());
|
||||
|
||||
return builder.toString();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.extra.system;
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.regex.ReUtil;
|
||||
@ -11,11 +11,11 @@ import java.io.Serializable;
|
||||
public class JavaInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final String JAVA_VERSION = SystemUtil.get("java.version", false);
|
||||
private final String JAVA_VERSION = ManagementUtil.get("java.version", false);
|
||||
private final float JAVA_VERSION_FLOAT = getJavaVersionAsFloat();
|
||||
private final int JAVA_VERSION_INT = getJavaVersionAsInt();
|
||||
private final String JAVA_VENDOR = SystemUtil.get("java.vendor", false);
|
||||
private final String JAVA_VENDOR_URL = SystemUtil.get("java.vendor.url", false);
|
||||
private final String JAVA_VENDOR = ManagementUtil.get("java.vendor", false);
|
||||
private final String JAVA_VENDOR_URL = ManagementUtil.get("java.vendor.url", false);
|
||||
|
||||
// 1.1--1.3能否识别?
|
||||
private final boolean IS_JAVA_1_1 = getJavaVersionMatches("1.1");
|
||||
@ -351,9 +351,9 @@ public class JavaInfo implements Serializable {
|
||||
public final String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
SystemUtil.append(builder, "Java Version: ", getVersion());
|
||||
SystemUtil.append(builder, "Java Vendor: ", getVendor());
|
||||
SystemUtil.append(builder, "Java Vendor URL: ", getVendorURL());
|
||||
ManagementUtil.append(builder, "Java Version: ", getVersion());
|
||||
ManagementUtil.append(builder, "Java Vendor: ", getVendor());
|
||||
ManagementUtil.append(builder, "Java Vendor URL: ", getVendorURL());
|
||||
|
||||
return builder.toString();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.extra.system;
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
||||
@ -10,18 +10,18 @@ import java.io.Serializable;
|
||||
public class JavaRuntimeInfo implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final String JAVA_RUNTIME_NAME = SystemUtil.get("java.runtime.name", false);
|
||||
private final String JAVA_RUNTIME_VERSION = SystemUtil.get("java.runtime.version", false);
|
||||
private final String JAVA_HOME = SystemUtil.get("java.home", false);
|
||||
private final String JAVA_EXT_DIRS = SystemUtil.get("java.ext.dirs", false);
|
||||
private final String JAVA_ENDORSED_DIRS = SystemUtil.get("java.endorsed.dirs", false);
|
||||
private final String JAVA_CLASS_PATH = SystemUtil.get("java.class.path", false);
|
||||
private final String JAVA_CLASS_VERSION = SystemUtil.get("java.class.version", false);
|
||||
private final String JAVA_LIBRARY_PATH = SystemUtil.get("java.library.path", false);
|
||||
private final String JAVA_RUNTIME_NAME = ManagementUtil.get("java.runtime.name", false);
|
||||
private final String JAVA_RUNTIME_VERSION = ManagementUtil.get("java.runtime.version", false);
|
||||
private final String JAVA_HOME = ManagementUtil.get("java.home", false);
|
||||
private final String JAVA_EXT_DIRS = ManagementUtil.get("java.ext.dirs", false);
|
||||
private final String JAVA_ENDORSED_DIRS = ManagementUtil.get("java.endorsed.dirs", false);
|
||||
private final String JAVA_CLASS_PATH = ManagementUtil.get("java.class.path", false);
|
||||
private final String JAVA_CLASS_VERSION = ManagementUtil.get("java.class.version", false);
|
||||
private final String JAVA_LIBRARY_PATH = ManagementUtil.get("java.library.path", false);
|
||||
|
||||
private final String SUN_BOOT_CLASS_PATH = SystemUtil.get("sun.boot.class.path", false);
|
||||
private final String SUN_BOOT_CLASS_PATH = ManagementUtil.get("sun.boot.class.path", false);
|
||||
|
||||
private final String SUN_ARCH_DATA_MODEL = SystemUtil.get("sun.arch.data.model", false);
|
||||
private final String SUN_ARCH_DATA_MODEL = ManagementUtil.get("sun.arch.data.model", false);
|
||||
|
||||
public final String getSunBoothClassPath() {
|
||||
return SUN_BOOT_CLASS_PATH;
|
||||
@ -138,7 +138,7 @@ public class JavaRuntimeInfo implements Serializable{
|
||||
* @since Java 1.1
|
||||
*/
|
||||
public final String[] getClassPathArray() {
|
||||
return StrUtil.splitToArray(getClassPath(), SystemUtil.get("path.separator", false));
|
||||
return StrUtil.splitToArray(getClassPath(), ManagementUtil.get("path.separator", false));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,7 +182,7 @@ public class JavaRuntimeInfo implements Serializable{
|
||||
*
|
||||
*/
|
||||
public final String[] getLibraryPathArray() {
|
||||
return StrUtil.splitToArray(getLibraryPath(), SystemUtil.get("path.separator", false));
|
||||
return StrUtil.splitToArray(getLibraryPath(), ManagementUtil.get("path.separator", false));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -197,7 +197,7 @@ public class JavaRuntimeInfo implements Serializable{
|
||||
*
|
||||
*/
|
||||
public final String getProtocolPackages() {
|
||||
return SystemUtil.get("java.protocol.handler.pkgs", true);
|
||||
return ManagementUtil.get("java.protocol.handler.pkgs", true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -209,15 +209,15 @@ public class JavaRuntimeInfo implements Serializable{
|
||||
public final String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
SystemUtil.append(builder, "Java Runtime Name: ", getName());
|
||||
SystemUtil.append(builder, "Java Runtime Version: ", getVersion());
|
||||
SystemUtil.append(builder, "Java Home Dir: ", getHomeDir());
|
||||
SystemUtil.append(builder, "Java Extension Dirs: ", getExtDirs());
|
||||
SystemUtil.append(builder, "Java Endorsed Dirs: ", getEndorsedDirs());
|
||||
SystemUtil.append(builder, "Java Class Path: ", getClassPath());
|
||||
SystemUtil.append(builder, "Java Class Version: ", getClassVersion());
|
||||
SystemUtil.append(builder, "Java Library Path: ", getLibraryPath());
|
||||
SystemUtil.append(builder, "Java Protocol Packages: ", getProtocolPackages());
|
||||
ManagementUtil.append(builder, "Java Runtime Name: ", getName());
|
||||
ManagementUtil.append(builder, "Java Runtime Version: ", getVersion());
|
||||
ManagementUtil.append(builder, "Java Home Dir: ", getHomeDir());
|
||||
ManagementUtil.append(builder, "Java Extension Dirs: ", getExtDirs());
|
||||
ManagementUtil.append(builder, "Java Endorsed Dirs: ", getEndorsedDirs());
|
||||
ManagementUtil.append(builder, "Java Class Path: ", getClassPath());
|
||||
ManagementUtil.append(builder, "Java Class Version: ", getClassVersion());
|
||||
ManagementUtil.append(builder, "Java Library Path: ", getLibraryPath());
|
||||
ManagementUtil.append(builder, "Java Protocol Packages: ", getProtocolPackages());
|
||||
|
||||
return builder.toString();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.extra.system;
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ -8,9 +8,9 @@ import java.io.Serializable;
|
||||
public class JavaSpecInfo implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final String JAVA_SPECIFICATION_NAME = SystemUtil.get("java.specification.name", false);
|
||||
private final String JAVA_SPECIFICATION_VERSION = SystemUtil.get("java.specification.version", false);
|
||||
private final String JAVA_SPECIFICATION_VENDOR = SystemUtil.get("java.specification.vendor", false);
|
||||
private final String JAVA_SPECIFICATION_NAME = ManagementUtil.get("java.specification.name", false);
|
||||
private final String JAVA_SPECIFICATION_VERSION = ManagementUtil.get("java.specification.version", false);
|
||||
private final String JAVA_SPECIFICATION_VENDOR = ManagementUtil.get("java.specification.vendor", false);
|
||||
|
||||
/**
|
||||
* 取得当前Java Spec.的名称(取自系统属性:{@code java.specification.name})。
|
||||
@ -64,9 +64,9 @@ public class JavaSpecInfo implements Serializable{
|
||||
public final String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
SystemUtil.append(builder, "Java Spec. Name: ", getName());
|
||||
SystemUtil.append(builder, "Java Spec. Version: ", getVersion());
|
||||
SystemUtil.append(builder, "Java Spec. Vendor: ", getVendor());
|
||||
ManagementUtil.append(builder, "Java Spec. Name: ", getName());
|
||||
ManagementUtil.append(builder, "Java Spec. Version: ", getVersion());
|
||||
ManagementUtil.append(builder, "Java Spec. Vendor: ", getVendor());
|
||||
|
||||
return builder.toString();
|
||||
}
|
18
hutool-extra/src/main/java/cn/hutool/extra/system/JvmInfo.java → hutool-extra/src/main/java/cn/hutool/extra/management/JvmInfo.java
Executable file → Normal file
18
hutool-extra/src/main/java/cn/hutool/extra/system/JvmInfo.java → hutool-extra/src/main/java/cn/hutool/extra/management/JvmInfo.java
Executable file → Normal file
@ -1,4 +1,4 @@
|
||||
package cn.hutool.extra.system;
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ -8,10 +8,10 @@ import java.io.Serializable;
|
||||
public class JvmInfo implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final String JAVA_VM_NAME = SystemUtil.get("java.vm.name", false);
|
||||
private final String JAVA_VM_VERSION = SystemUtil.get("java.vm.version", false);
|
||||
private final String JAVA_VM_VENDOR = SystemUtil.get("java.vm.vendor", false);
|
||||
private final String JAVA_VM_INFO = SystemUtil.get("java.vm.info", false);
|
||||
private final String JAVA_VM_NAME = ManagementUtil.get("java.vm.name", false);
|
||||
private final String JAVA_VM_VERSION = ManagementUtil.get("java.vm.version", false);
|
||||
private final String JAVA_VM_VENDOR = ManagementUtil.get("java.vm.vendor", false);
|
||||
private final String JAVA_VM_INFO = ManagementUtil.get("java.vm.info", false);
|
||||
|
||||
/**
|
||||
* 取得当前JVM impl.的名称(取自系统属性:{@code java.vm.name})。
|
||||
@ -78,10 +78,10 @@ public class JvmInfo implements Serializable{
|
||||
public final String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
SystemUtil.append(builder, "JavaVM Name: ", getName());
|
||||
SystemUtil.append(builder, "JavaVM Version: ", getVersion());
|
||||
SystemUtil.append(builder, "JavaVM Vendor: ", getVendor());
|
||||
SystemUtil.append(builder, "JavaVM Info: ", getInfo());
|
||||
ManagementUtil.append(builder, "JavaVM Name: ", getName());
|
||||
ManagementUtil.append(builder, "JavaVM Version: ", getVersion());
|
||||
ManagementUtil.append(builder, "JavaVM Vendor: ", getVendor());
|
||||
ManagementUtil.append(builder, "JavaVM Info: ", getInfo());
|
||||
|
||||
return builder.toString();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.extra.system;
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ -8,9 +8,9 @@ import java.io.Serializable;
|
||||
public class JvmSpecInfo implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final String JAVA_VM_SPECIFICATION_NAME = SystemUtil.get("java.vm.specification.name", false);
|
||||
private final String JAVA_VM_SPECIFICATION_VERSION = SystemUtil.get("java.vm.specification.version", false);
|
||||
private final String JAVA_VM_SPECIFICATION_VENDOR = SystemUtil.get("java.vm.specification.vendor", false);
|
||||
private final String JAVA_VM_SPECIFICATION_NAME = ManagementUtil.get("java.vm.specification.name", false);
|
||||
private final String JAVA_VM_SPECIFICATION_VERSION = ManagementUtil.get("java.vm.specification.version", false);
|
||||
private final String JAVA_VM_SPECIFICATION_VENDOR = ManagementUtil.get("java.vm.specification.vendor", false);
|
||||
|
||||
/**
|
||||
* 取得当前JVM spec.的名称(取自系统属性:{@code java.vm.specification.name})。
|
||||
@ -63,9 +63,9 @@ public class JvmSpecInfo implements Serializable{
|
||||
public final String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
SystemUtil.append(builder, "JavaVM Spec. Name: ", getName());
|
||||
SystemUtil.append(builder, "JavaVM Spec. Version: ", getVersion());
|
||||
SystemUtil.append(builder, "JavaVM Spec. Vendor: ", getVendor());
|
||||
ManagementUtil.append(builder, "JavaVM Spec. Name: ", getName());
|
||||
ManagementUtil.append(builder, "JavaVM Spec. Version: ", getVersion());
|
||||
ManagementUtil.append(builder, "JavaVM Spec. Vendor: ", getVendor());
|
||||
|
||||
return builder.toString();
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
package cn.hutool.extra.system;
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Singleton;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.core.util.SystemPropsUtil;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.management.ClassLoadingMXBean;
|
||||
@ -24,7 +23,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Looly
|
||||
*/
|
||||
public class SystemUtil extends SystemPropsUtil {
|
||||
public class ManagementUtil {
|
||||
|
||||
// ----- Java运行时环境信息 -----/
|
||||
/**
|
26
hutool-extra/src/main/java/cn/hutool/extra/system/OsInfo.java → hutool-extra/src/main/java/cn/hutool/extra/management/OsInfo.java
Executable file → Normal file
26
hutool-extra/src/main/java/cn/hutool/extra/system/OsInfo.java → hutool-extra/src/main/java/cn/hutool/extra/management/OsInfo.java
Executable file → Normal file
@ -1,4 +1,4 @@
|
||||
package cn.hutool.extra.system;
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ -8,9 +8,9 @@ import java.io.Serializable;
|
||||
public class OsInfo implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final String OS_VERSION = SystemUtil.get("os.version", false);
|
||||
private final String OS_ARCH = SystemUtil.get("os.arch", false);
|
||||
private final String OS_NAME = SystemUtil.get("os.name", false);
|
||||
private final String OS_VERSION = ManagementUtil.get("os.version", false);
|
||||
private final String OS_ARCH = ManagementUtil.get("os.arch", false);
|
||||
private final String OS_NAME = ManagementUtil.get("os.name", false);
|
||||
private final boolean IS_OS_AIX = getOSMatches("AIX");
|
||||
private final boolean IS_OS_HP_UX = getOSMatches("HP-UX");
|
||||
private final boolean IS_OS_IRIX = getOSMatches("Irix");
|
||||
@ -34,9 +34,9 @@ public class OsInfo implements Serializable{
|
||||
private final boolean IS_OS_WINDOWS_10 = getOSMatches("Windows", "10.0");
|
||||
|
||||
// 由于改变file.encoding属性并不会改变系统字符编码,为了保持一致,通过LocaleUtil取系统默认编码。
|
||||
private final String FILE_SEPARATOR = SystemUtil.get("file.separator", false);
|
||||
private final String LINE_SEPARATOR = SystemUtil.get("line.separator", false);
|
||||
private final String PATH_SEPARATOR = SystemUtil.get("path.separator", false);
|
||||
private final String FILE_SEPARATOR = ManagementUtil.get("file.separator", false);
|
||||
private final String LINE_SEPARATOR = ManagementUtil.get("line.separator", false);
|
||||
private final String PATH_SEPARATOR = ManagementUtil.get("path.separator", false);
|
||||
|
||||
/**
|
||||
* 取得当前OS的架构(取自系统属性:{@code os.arch})。
|
||||
@ -428,12 +428,12 @@ public class OsInfo implements Serializable{
|
||||
public final String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
SystemUtil.append(builder, "OS Arch: ", getArch());
|
||||
SystemUtil.append(builder, "OS Name: ", getName());
|
||||
SystemUtil.append(builder, "OS Version: ", getVersion());
|
||||
SystemUtil.append(builder, "File Separator: ", getFileSeparator());
|
||||
SystemUtil.append(builder, "Line Separator: ", getLineSeparator());
|
||||
SystemUtil.append(builder, "Path Separator: ", getPathSeparator());
|
||||
ManagementUtil.append(builder, "OS Arch: ", getArch());
|
||||
ManagementUtil.append(builder, "OS Name: ", getName());
|
||||
ManagementUtil.append(builder, "OS Version: ", getVersion());
|
||||
ManagementUtil.append(builder, "File Separator: ", getFileSeparator());
|
||||
ManagementUtil.append(builder, "Line Separator: ", getLineSeparator());
|
||||
ManagementUtil.append(builder, "Path Separator: ", getPathSeparator());
|
||||
|
||||
return builder.toString();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.extra.system;
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
|
||||
@ -63,10 +63,10 @@ public class RuntimeInfo implements Serializable {
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
SystemUtil.append(builder, "Max Memory: ", FileUtil.readableFileSize(getMaxMemory()));
|
||||
SystemUtil.append(builder, "Total Memory: ", FileUtil.readableFileSize(getTotalMemory()));
|
||||
SystemUtil.append(builder, "Free Memory: ", FileUtil.readableFileSize(getFreeMemory()));
|
||||
SystemUtil.append(builder, "Usable Memory: ", FileUtil.readableFileSize(getUsableMemory()));
|
||||
ManagementUtil.append(builder, "Max Memory: ", FileUtil.readableFileSize(getMaxMemory()));
|
||||
ManagementUtil.append(builder, "Total Memory: ", FileUtil.readableFileSize(getTotalMemory()));
|
||||
ManagementUtil.append(builder, "Free Memory: ", FileUtil.readableFileSize(getFreeMemory()));
|
||||
ManagementUtil.append(builder, "Usable Memory: ", FileUtil.readableFileSize(getUsableMemory()));
|
||||
|
||||
return builder.toString();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.extra.system;
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
/**
|
||||
* 系统属性名称常量池
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.extra.system;
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
||||
@ -19,16 +19,16 @@ public class UserInfo implements Serializable{
|
||||
private final String USER_COUNTRY;
|
||||
|
||||
public UserInfo(){
|
||||
USER_NAME = fixPath(SystemUtil.get("user.name", false));
|
||||
USER_HOME = fixPath(SystemUtil.get("user.home", false));
|
||||
USER_DIR = fixPath(SystemUtil.get("user.dir", false));
|
||||
JAVA_IO_TMPDIR = fixPath(SystemUtil.get("java.io.tmpdir", false));
|
||||
USER_LANGUAGE = SystemUtil.get("user.language", false);
|
||||
USER_NAME = fixPath(ManagementUtil.get("user.name", false));
|
||||
USER_HOME = fixPath(ManagementUtil.get("user.home", false));
|
||||
USER_DIR = fixPath(ManagementUtil.get("user.dir", false));
|
||||
JAVA_IO_TMPDIR = fixPath(ManagementUtil.get("java.io.tmpdir", false));
|
||||
USER_LANGUAGE = ManagementUtil.get("user.language", false);
|
||||
|
||||
// JDK1.4 {@code user.country},JDK1.2 {@code user.region}
|
||||
String userCountry = SystemUtil.get("user.country", false);
|
||||
String userCountry = ManagementUtil.get("user.country", false);
|
||||
if(null == userCountry){
|
||||
userCountry = SystemUtil.get("user.country", false);
|
||||
userCountry = ManagementUtil.get("user.country", false);
|
||||
}
|
||||
USER_COUNTRY = userCountry;
|
||||
}
|
||||
@ -130,12 +130,12 @@ public class UserInfo implements Serializable{
|
||||
public final String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
SystemUtil.append(builder, "User Name: ", getName());
|
||||
SystemUtil.append(builder, "User Home Dir: ", getHomeDir());
|
||||
SystemUtil.append(builder, "User Current Dir: ", getCurrentDir());
|
||||
SystemUtil.append(builder, "User Temp Dir: ", getTempDir());
|
||||
SystemUtil.append(builder, "User Language: ", getLanguage());
|
||||
SystemUtil.append(builder, "User Country: ", getCountry());
|
||||
ManagementUtil.append(builder, "User Name: ", getName());
|
||||
ManagementUtil.append(builder, "User Home Dir: ", getHomeDir());
|
||||
ManagementUtil.append(builder, "User Current Dir: ", getCurrentDir());
|
||||
ManagementUtil.append(builder, "User Temp Dir: ", getTempDir());
|
||||
ManagementUtil.append(builder, "User Language: ", getLanguage());
|
||||
ManagementUtil.append(builder, "User Country: ", getCountry());
|
||||
|
||||
return builder.toString();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.extra.system.oshi;
|
||||
package cn.hutool.extra.management.oshi;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import oshi.hardware.CentralProcessor;
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.extra.system.oshi;
|
||||
package cn.hutool.extra.management.oshi;
|
||||
|
||||
import oshi.hardware.CentralProcessor;
|
||||
import oshi.util.Util;
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.extra.system.oshi;
|
||||
package cn.hutool.extra.management.oshi;
|
||||
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.CentralProcessor;
|
@ -5,4 +5,4 @@
|
||||
* @author Looly
|
||||
* @since 4.6.4
|
||||
*/
|
||||
package cn.hutool.extra.system.oshi;
|
||||
package cn.hutool.extra.management.oshi;
|
@ -4,4 +4,4 @@
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
package cn.hutool.extra.system;
|
||||
package cn.hutool.extra.management;
|
@ -1,7 +1,7 @@
|
||||
package cn.hutool.extra.system;
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.extra.system.oshi.OshiUtil;
|
||||
import cn.hutool.extra.management.oshi.OshiUtil;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cn.hutool.extra.system;
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.extra.system.oshi.CpuInfo;
|
||||
import cn.hutool.extra.system.oshi.OshiUtil;
|
||||
import cn.hutool.extra.management.oshi.CpuInfo;
|
||||
import cn.hutool.extra.management.oshi.OshiUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.extra.system;
|
||||
package cn.hutool.extra.management;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
@ -11,43 +11,43 @@ public class SystemUtilTest {
|
||||
@Test
|
||||
@Ignore
|
||||
public void dumpTest() {
|
||||
SystemUtil.dumpSystemInfo();
|
||||
ManagementUtil.dumpSystemInfo();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCurrentPidTest() {
|
||||
long pid = SystemUtil.getCurrentPID();
|
||||
long pid = ManagementUtil.getCurrentPID();
|
||||
Assert.assertTrue(pid > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getJavaInfoTest() {
|
||||
JavaInfo javaInfo = SystemUtil.getJavaInfo();
|
||||
JavaInfo javaInfo = ManagementUtil.getJavaInfo();
|
||||
Assert.assertNotNull(javaInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getJavaRuntimeInfoTest() {
|
||||
JavaRuntimeInfo info = SystemUtil.getJavaRuntimeInfo();
|
||||
JavaRuntimeInfo info = ManagementUtil.getJavaRuntimeInfo();
|
||||
Assert.assertNotNull(info);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getOsInfoTest() {
|
||||
OsInfo osInfo = SystemUtil.getOsInfo();
|
||||
OsInfo osInfo = ManagementUtil.getOsInfo();
|
||||
Assert.assertNotNull(osInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHostInfo() {
|
||||
HostInfo hostInfo = SystemUtil.getHostInfo();
|
||||
HostInfo hostInfo = ManagementUtil.getHostInfo();
|
||||
Assert.assertNotNull(hostInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUserInfoTest(){
|
||||
// https://gitee.com/dromara/hutool/issues/I3NM39
|
||||
final UserInfo userInfo = SystemUtil.getUserInfo();
|
||||
final UserInfo userInfo = ManagementUtil.getUserInfo();
|
||||
Assert.assertTrue(userInfo.getTempDir().endsWith(File.separator));
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package cn.hutool.poi;
|
||||
|
||||
import cn.hutool.core.exceptions.DependencyException;
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.classloader.ClassLoaderUtil;
|
||||
|
||||
/**
|
||||
* POI引入检查器
|
||||
*
|
||||
*
|
||||
* @author looly
|
||||
* @since 4.0.10
|
||||
*/
|
||||
|
@ -8,7 +8,7 @@ import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.regex.ReUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.core.util.SystemPropsUtil;
|
||||
import cn.hutool.core.util.SystemUtil;
|
||||
import cn.hutool.log.Log;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -233,7 +233,7 @@ public class SettingLoader {
|
||||
}
|
||||
// 系统参数和环境变量中查找
|
||||
if (null == varValue) {
|
||||
varValue = SystemPropsUtil.get(key);
|
||||
varValue = SystemUtil.get(key);
|
||||
}
|
||||
|
||||
if (null != varValue) {
|
||||
|
Loading…
Reference in New Issue
Block a user