diff --git a/README.md b/README.md index 4f0d63e754..67b3e4a938 100755 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@

- + @@ -97,7 +97,7 @@ Bus (应用/服务总线) 是一个基础框架、服务套件,它基于Java17 org.aoju bus-all - 6.5.6 + 6.5.8 ``` diff --git a/bus-all/pom.xml b/bus-all/pom.xml index 5de15a52d5..830739d681 100755 --- a/bus-all/pom.xml +++ b/bus-all/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-all - 6.5.6 + 6.5.8 jar ${project.artifactId} diff --git a/bus-base/pom.xml b/bus-base/pom.xml index 7e47157de1..0fbfa9c201 100755 --- a/bus-base/pom.xml +++ b/bus-base/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-base - 6.5.6 + 6.5.8 jar ${project.artifactId} @@ -42,7 +42,7 @@ UTF-8 UTF-8 17 - 2.7.2 + 2.7.3 1.18.24 2.2 diff --git a/bus-base/src/main/java/org/aoju/bus/base/advice/BaseAdvice.java b/bus-base/src/main/java/org/aoju/bus/base/advice/BaseAdvice.java index 9c4b5f79e5..7c79630585 100755 --- a/bus-base/src/main/java/org/aoju/bus/base/advice/BaseAdvice.java +++ b/bus-base/src/main/java/org/aoju/bus/base/advice/BaseAdvice.java @@ -29,7 +29,7 @@ import org.aoju.bus.base.spring.Controller; import org.aoju.bus.core.exception.BusinessException; import org.aoju.bus.core.exception.CrontabException; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.exception.ValidateException; import org.aoju.bus.core.instance.Instances; import org.aoju.bus.core.toolkit.StringKit; @@ -97,8 +97,8 @@ public Object defaultException(Exception e) { * @return 异常提示 */ @ResponseBody - @ExceptionHandler(value = InstrumentException.class) - public Object instrumentException(InstrumentException e) { + @ExceptionHandler(value = InternalException.class) + public Object InternalException(InternalException e) { this.defaultExceptionHandler(e); if (StringKit.isBlank(e.getErrcode())) { return write(ErrorCode.EM_100510); diff --git a/bus-base/src/main/java/org/aoju/bus/base/advice/ErrorAdvice.java b/bus-base/src/main/java/org/aoju/bus/base/advice/ErrorAdvice.java index 77f82b6cf8..b8d88eed28 100755 --- a/bus-base/src/main/java/org/aoju/bus/base/advice/ErrorAdvice.java +++ b/bus-base/src/main/java/org/aoju/bus/base/advice/ErrorAdvice.java @@ -26,9 +26,8 @@ package org.aoju.bus.base.advice; import org.aoju.bus.base.service.ErrorService; -import org.aoju.bus.core.toolkit.RuntimeKit; -import org.aoju.bus.logger.Logger; -import org.aoju.bus.spring.SpringBuilder; + +import java.util.ServiceLoader; /** * 异常信息处理 @@ -47,19 +46,21 @@ public class ErrorAdvice { * @return 如果执行链应该继续执行, 则为:true 否则:false */ public boolean handler(Exception ex) { - ErrorService errorService = null; - try { - errorService = SpringBuilder.getBean(ErrorService.class); - } catch (RuntimeException ignore) { - - } - if (null != errorService) { - errorService.before(ex); - errorService.after(ex); - } else { - Logger.error(RuntimeKit.getStackTrace(ex)); + final ServiceLoader loader = ServiceLoader.load(ErrorService.class); + for (ErrorService service : loader) { + if (service instanceof ErrorService) { + if (loader.stream().count() > 1) { + if (!service.getClass().getName().equals(ErrorService.class.getName())) { + service.before(ex); + service.after(ex); + } + } else { + service.before(ex); + service.after(ex); + } + } } return true; } -} +} \ No newline at end of file diff --git a/bus-base/src/main/java/org/aoju/bus/base/consts/ErrorCode.java b/bus-base/src/main/java/org/aoju/bus/base/consts/ErrorCode.java index bbf6a73a76..4c12c1bf3d 100755 --- a/bus-base/src/main/java/org/aoju/bus/base/consts/ErrorCode.java +++ b/bus-base/src/main/java/org/aoju/bus/base/consts/ErrorCode.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.base.consts; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Symbol; import java.util.Map; @@ -301,7 +301,7 @@ public class ErrorCode { */ public static void register(String key, String value) { if (ERRORCODE_CACHE.containsKey(key)) { - throw new InstrumentException("重复注册同名称的错误码:" + key); + throw new InternalException("重复注册同名称的错误码:" + key); } ERRORCODE_CACHE.putIfAbsent(key, value); } diff --git a/bus-base/src/main/java/org/aoju/bus/base/service/ErrorService.java b/bus-base/src/main/java/org/aoju/bus/base/service/ErrorService.java index d002271cf4..b1d237a21e 100644 --- a/bus-base/src/main/java/org/aoju/bus/base/service/ErrorService.java +++ b/bus-base/src/main/java/org/aoju/bus/base/service/ErrorService.java @@ -25,18 +25,25 @@ ********************************************************************************/ package org.aoju.bus.base.service; +import lombok.NoArgsConstructor; import org.aoju.bus.core.toolkit.RuntimeKit; import org.aoju.bus.logger.Logger; /** * 异常信息处理 * 此类未找到实现的情况下,采用默认实现 - * 可以根据不同业务需求,实现对应逻辑即可 + * 可以根据不同业务需求,继承此类实现对应业务逻辑即可 + * 项目中可通过SPI自定义接入 + * 例:META-INF/services/org.aoju.bus.base.service.ErrorService + * + * org.aoju.bus.xxx.ErrorService + * * * @author Kimi Liu * @since Java 17+ */ -public interface ErrorService { +@NoArgsConstructor +public class ErrorService { /** * 完成请求处理前调用 @@ -44,7 +51,7 @@ public interface ErrorService { * @param ex 对象参数 * @return 如果执行链应该继续执行, 则为:true 否则:false */ - default boolean before(Exception ex) { + public boolean before(Exception ex) { Logger.error(RuntimeKit.getStackTrace(ex)); return true; } @@ -55,8 +62,8 @@ default boolean before(Exception ex) { * @param ex 对象参数 * @return 如果执行链应该继续执行, 则为:true 否则:false */ - default boolean after(Exception ex) { + public boolean after(Exception ex) { return true; } -} +} \ No newline at end of file diff --git a/bus-base/src/main/resources/META-INF/services/org.aoju.bus.base.service.ErrorService b/bus-base/src/main/resources/META-INF/services/org.aoju.bus.base.service.ErrorService new file mode 100644 index 0000000000..f283f9d40c --- /dev/null +++ b/bus-base/src/main/resources/META-INF/services/org.aoju.bus.base.service.ErrorService @@ -0,0 +1 @@ +org.aoju.bus.base.service.ErrorService \ No newline at end of file diff --git a/bus-bom/pom.xml b/bus-bom/pom.xml index 85c39e0c13..14815ce8f5 100755 --- a/bus-bom/pom.xml +++ b/bus-bom/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-bom - 6.5.6 + 6.5.8 pom ${project.artifactId} diff --git a/bus-cache/pom.xml b/bus-cache/pom.xml index 698c41835e..b3b40d8e32 100755 --- a/bus-cache/pom.xml +++ b/bus-cache/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-cache - 6.5.6 + 6.5.8 jar ${project.artifactId} @@ -42,7 +42,7 @@ UTF-8 UTF-8 17 - 2.7.2 + 2.7.3 1.18.24 5.1.0 4.2.3 diff --git a/bus-cache/src/main/java/org/aoju/bus/cache/Manage.java b/bus-cache/src/main/java/org/aoju/bus/cache/Manage.java index b696026f26..273893c29d 100755 --- a/bus-cache/src/main/java/org/aoju/bus/cache/Manage.java +++ b/bus-cache/src/main/java/org/aoju/bus/cache/Manage.java @@ -29,7 +29,7 @@ import org.aoju.bus.cache.magic.CachePair; import org.aoju.bus.core.annotation.Inject; import org.aoju.bus.core.annotation.Singleton; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.StringKit; import org.aoju.bus.logger.Logger; @@ -163,7 +163,7 @@ private CachePair getCacheImpl(String cacheName) { return defaultCache; } else { return cachePool.computeIfAbsent(cacheName, (key) -> { - throw new InstrumentException(StringKit.format("no cache implementation named [%s].", key)); + throw new InternalException(StringKit.format("no cache implementation named [%s].", key)); }); } } diff --git a/bus-cache/src/main/java/org/aoju/bus/cache/provider/MySQLHitting.java b/bus-cache/src/main/java/org/aoju/bus/cache/provider/MySQLHitting.java index bea715228f..af012de764 100755 --- a/bus-cache/src/main/java/org/aoju/bus/cache/provider/MySQLHitting.java +++ b/bus-cache/src/main/java/org/aoju/bus/cache/provider/MySQLHitting.java @@ -27,7 +27,7 @@ import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; @@ -71,7 +71,7 @@ protected Supplier jdbcOperationsSupplier(Map co return template; } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } }; } diff --git a/bus-cache/src/main/java/org/aoju/bus/cache/serialize/JdkSerializer.java b/bus-cache/src/main/java/org/aoju/bus/cache/serialize/JdkSerializer.java index bae0ba6dbf..a75b2127fa 100755 --- a/bus-cache/src/main/java/org/aoju/bus/cache/serialize/JdkSerializer.java +++ b/bus-cache/src/main/java/org/aoju/bus/cache/serialize/JdkSerializer.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.cache.serialize; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Normal; import org.aoju.bus.logger.Logger; @@ -47,7 +47,7 @@ private static void serialize(Serializable object, OutputStream outputStream) { out = new ObjectOutputStream(outputStream); out.writeObject(object); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { try { if (null != out) { @@ -71,7 +71,7 @@ private static Object deserialize(InputStream inputStream) { in = new ObjectInputStream(inputStream); result = in.readObject(); } catch (ClassCastException | IOException | ClassNotFoundException ce) { - throw new InstrumentException(ce); + throw new InternalException(ce); } finally { try { if (null != in) { diff --git a/bus-core/README.md b/bus-core/README.md index 9eb41dca3d..8a5ea5044b 100755 --- a/bus-core/README.md +++ b/bus-core/README.md @@ -14,7 +14,7 @@ org.aoju bus-core - 6.5.6 + 6.5.8 ``` diff --git a/bus-core/pom.xml b/bus-core/pom.xml index 86b7e333ee..94c126dab9 100755 --- a/bus-core/pom.xml +++ b/bus-core/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-core - 6.5.6 + 6.5.8 jar ${project.artifactId} diff --git a/bus-core/src/main/java/org/aoju/bus/core/Binder.java b/bus-core/src/main/java/org/aoju/bus/core/Binder.java index c5bc5dc23b..aef6522016 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/Binder.java +++ b/bus-core/src/main/java/org/aoju/bus/core/Binder.java @@ -29,7 +29,7 @@ import org.aoju.bus.core.annotation.Ignore; import org.aoju.bus.core.annotation.Values; import org.aoju.bus.core.convert.Convert; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.resource.PropertySource; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Symbol; @@ -159,7 +159,7 @@ public T bind(Class clazz, String prefix) { try { object = clazz.getConstructor().newInstance(); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } Class actualClass = ClassKit.getCglibActualClass(clazz); diff --git a/bus-core/src/main/java/org/aoju/bus/core/Version.java b/bus-core/src/main/java/org/aoju/bus/core/Version.java index 73010b4c56..625993bbc2 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/Version.java +++ b/bus-core/src/main/java/org/aoju/bus/core/Version.java @@ -60,7 +60,7 @@ public class Version { * @return 项目的版本号 */ public static String get() { - return "6.5.6.RELEASE"; + return "6.5.8.RELEASE"; } /** diff --git a/bus-core/src/main/java/org/aoju/bus/core/beans/DynamicBean.java b/bus-core/src/main/java/org/aoju/bus/core/beans/DynamicBean.java index 3f1a182b90..9ecce0406e 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/beans/DynamicBean.java +++ b/bus-core/src/main/java/org/aoju/bus/core/beans/DynamicBean.java @@ -26,7 +26,7 @@ package org.aoju.bus.core.beans; import org.aoju.bus.core.clone.Cloning; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.toolkit.BeanKit; import org.aoju.bus.core.toolkit.ClassKit; @@ -130,15 +130,15 @@ public Object invoke(String methodName, Object... params) { * @param 属性值类型 * @param fieldName 字段名 * @return 字段值 - * @throws InstrumentException 反射获取属性值或字段值导致的异常 + * @throws InternalException 反射获取属性值或字段值导致的异常 */ - public T get(String fieldName) throws InstrumentException { + public T get(String fieldName) throws InternalException { if (Map.class.isAssignableFrom(beanClass)) { return (T) ((Map) bean).get(fieldName); } else { final PropertyDesc prop = BeanKit.getBeanDesc(beanClass).getProp(fieldName); if (null == prop) { - throw new InstrumentException("No public field or get method for {}", fieldName); + throw new InternalException("No public field or get method for {}", fieldName); } return (T) prop.getValue(bean); } @@ -149,15 +149,15 @@ public T get(String fieldName) throws InstrumentException { * * @param fieldName 字段名 * @param value 字段值 - * @throws InstrumentException 反射获取属性值或字段值导致的异常 + * @throws InternalException 反射获取属性值或字段值导致的异常 */ - public void set(String fieldName, Object value) throws InstrumentException { + public void set(String fieldName, Object value) throws InternalException { if (Map.class.isAssignableFrom(beanClass)) { ((Map) bean).put(fieldName, value); } else { final PropertyDesc prop = BeanKit.getBeanDesc(beanClass).getProp(fieldName); if (null == prop) { - throw new InstrumentException("No public field or set method for {}", fieldName); + throw new InternalException("No public field or set method for {}", fieldName); } prop.setValue(bean, value); } diff --git a/bus-core/src/main/java/org/aoju/bus/core/beans/PropertyDesc.java b/bus-core/src/main/java/org/aoju/bus/core/beans/PropertyDesc.java index c00541371a..688e5ee8e4 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/beans/PropertyDesc.java +++ b/bus-core/src/main/java/org/aoju/bus/core/beans/PropertyDesc.java @@ -28,7 +28,7 @@ import org.aoju.bus.core.annotation.Alias; import org.aoju.bus.core.annotation.Ignore; import org.aoju.bus.core.convert.Convert; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.*; import java.beans.Transient; @@ -195,7 +195,7 @@ public Object getValue(Object bean, Type targetType, boolean ignoreError) { result = getValue(bean); } catch (Exception e) { if (false == ignoreError) { - throw new InstrumentException("Get value of [{}] error!", getFieldName()); + throw new InternalException("Get value of [{}] error!", getFieldName()); } } @@ -294,7 +294,7 @@ public PropertyDesc setValue(Object bean, Object value, boolean ignoreNull, bool this.setValue(bean, value); } catch (Exception e) { if (false == ignoreError) { - throw new InstrumentException("Set value of [{}] error!", getFieldName()); + throw new InternalException("Set value of [{}] error!", getFieldName()); } // 忽略注入失败 } diff --git a/bus-core/src/main/java/org/aoju/bus/core/clone/Cloning.java b/bus-core/src/main/java/org/aoju/bus/core/clone/Cloning.java index 89a5d6c4d6..1d115b2178 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/clone/Cloning.java +++ b/bus-core/src/main/java/org/aoju/bus/core/clone/Cloning.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.clone; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; /** * 克隆支持类,提供默认的克隆方法 @@ -41,7 +41,7 @@ public T clone() { try { return (T) super.clone(); } catch (CloneNotSupportedException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/codec/Base58.java b/bus-core/src/main/java/org/aoju/bus/core/codec/Base58.java index 5ebb00cd4f..de2cb3a86a 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/codec/Base58.java +++ b/bus-core/src/main/java/org/aoju/bus/core/codec/Base58.java @@ -26,7 +26,7 @@ package org.aoju.bus.core.codec; import org.aoju.bus.core.codec.provider.Base58Provider; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.exception.ValidateException; import org.aoju.bus.core.lang.Algorithm; @@ -169,7 +169,7 @@ private static byte[] hash256(byte[] data) { try { return MessageDigest.getInstance(Algorithm.SHA256.getValue()).digest(data); } catch (NoSuchAlgorithmException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/codec/Base64.java b/bus-core/src/main/java/org/aoju/bus/core/codec/Base64.java index db5b3043a8..ee2f3346f3 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/codec/Base64.java +++ b/bus-core/src/main/java/org/aoju/bus/core/codec/Base64.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.codec; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.lang.Normal; import org.aoju.bus.core.lang.Symbol; @@ -474,7 +474,7 @@ public static void decode(char[] ch, int off, int len, OutputStream out) { out.write((byte) ((b3 << 6) | Normal.DECODE_64_TABLE[ch[off++]])); } } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/codec/PunyCode.java b/bus-core/src/main/java/org/aoju/bus/core/codec/PunyCode.java index f259d8b275..4f26b4f7ab 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/codec/PunyCode.java +++ b/bus-core/src/main/java/org/aoju/bus/core/codec/PunyCode.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.codec; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Symbol; import org.aoju.bus.core.toolkit.StringKit; @@ -55,9 +55,9 @@ public class PunyCode { * * @param input 字符串 * @return PunyCode字符串 - * @throws InstrumentException 计算异常 + * @throws InternalException 计算异常 */ - public static String encode(CharSequence input) throws InstrumentException { + public static String encode(CharSequence input) throws InternalException { return encode(input, false); } @@ -67,9 +67,9 @@ public static String encode(CharSequence input) throws InstrumentException { * @param input 字符串 * @param withPrefix 是否包含 "xn--"前缀 * @return PunyCode字符串 - * @throws InstrumentException 计算异常 + * @throws InternalException 计算异常 */ - public static String encode(CharSequence input, boolean withPrefix) throws InstrumentException { + public static String encode(CharSequence input, boolean withPrefix) throws InternalException { Assert.notNull(input, "input must not be null!"); int n = INITIAL_N; int delta = 0; @@ -100,7 +100,7 @@ public static String encode(CharSequence input, boolean withPrefix) throws Instr } } if (m - n > (Integer.MAX_VALUE - delta) / (h + 1)) { - throw new InstrumentException("OVERFLOW"); + throw new InternalException("OVERFLOW"); } delta = delta + (m - n) * (h + 1); n = m; @@ -109,7 +109,7 @@ public static String encode(CharSequence input, boolean withPrefix) throws Instr if (c < n) { delta++; if (0 == delta) { - throw new InstrumentException("OVERFLOW"); + throw new InternalException("OVERFLOW"); } } if (c == n) { @@ -150,9 +150,9 @@ public static String encode(CharSequence input, boolean withPrefix) throws Instr * * @param input PunyCode * @return 字符串 - * @throws InstrumentException 计算异常 + * @throws InternalException 计算异常 */ - public static String decode(String input) throws InstrumentException { + public static String decode(String input) throws InternalException { Assert.notNull(input, "input must not be null!"); input = StringKit.removePrefixIgnoreCase(input, PUNY_CODE_PREFIX); @@ -178,12 +178,12 @@ public static String decode(String input) throws InstrumentException { int w = 1; for (int k = BASE; ; k += BASE) { if (d == length) { - throw new InstrumentException("BAD_INPUT"); + throw new InternalException("BAD_INPUT"); } int c = input.charAt(d++); int digit = codepoint2digit(c); if (digit > (Integer.MAX_VALUE - i) / w) { - throw new InstrumentException("OVERFLOW"); + throw new InternalException("OVERFLOW"); } i = i + digit * w; int t; @@ -201,7 +201,7 @@ public static String decode(String input) throws InstrumentException { } bias = adapt(i - oldi, output.length() + 1, oldi == 0); if (i / (output.length() + 1) > Integer.MAX_VALUE - n) { - throw new InstrumentException("OVERFLOW"); + throw new InternalException("OVERFLOW"); } n = n + i / (output.length() + 1); i = i % (output.length() + 1); @@ -245,9 +245,9 @@ private static boolean isBasic(char c) { * * @param d 输入字符 * @return 转换后的字符 - * @throws InstrumentException 无效字符 + * @throws InternalException 无效字符 */ - private static int digit2codepoint(int d) throws InstrumentException { + private static int digit2codepoint(int d) throws InternalException { Assert.checkBetween(d, 0, 35); if (d < 26) { // 0..25 : 'a'..'z' @@ -256,7 +256,7 @@ private static int digit2codepoint(int d) throws InstrumentException { // 26..35 : '0'..'9'; return d - 26 + '0'; } else { - throw new InstrumentException("BAD_INPUT"); + throw new InternalException("BAD_INPUT"); } } @@ -274,9 +274,9 @@ private static int digit2codepoint(int d) throws InstrumentException { * * @param c 输入字符 * @return 转换后的字符 - * @throws InstrumentException 无效字符 + * @throws InternalException 无效字符 */ - private static int codepoint2digit(int c) throws InstrumentException { + private static int codepoint2digit(int c) throws InternalException { if (c - '0' < 10) { // '0'..'9' : 26..35 return c - '0' + 26; @@ -284,7 +284,7 @@ private static int codepoint2digit(int c) throws InstrumentException { // 'a'..'z' : 0..25 return c - 'a'; } else { - throw new InstrumentException("BAD_INPUT"); + throw new InternalException("BAD_INPUT"); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/codec/provider/Base16Provider.java b/bus-core/src/main/java/org/aoju/bus/core/codec/provider/Base16Provider.java index c77169a630..fdd0ab92a7 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/codec/provider/Base16Provider.java +++ b/bus-core/src/main/java/org/aoju/bus/core/codec/provider/Base16Provider.java @@ -27,7 +27,7 @@ import org.aoju.bus.core.codec.Decoder; import org.aoju.bus.core.codec.Encoder; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.StringKit; /** @@ -60,12 +60,12 @@ public Base16Provider(boolean lowerCase) { * @param ch 十六进制char * @param index 十六进制字符在字符数组中的位置 * @return 一个整数 - * @throws InstrumentException 当ch不是一个合法的十六进制字符时,抛出运行时异常 + * @throws InternalException 当ch不是一个合法的十六进制字符时,抛出运行时异常 */ private static int toDigit(char ch, int index) { int digit = Character.digit(ch, 16); if (digit < 0) { - throw new InstrumentException("Illegal hexadecimal character {} at index {}", ch, index); + throw new InternalException("Illegal hexadecimal character {} at index {}", ch, index); } return digit; } diff --git a/bus-core/src/main/java/org/aoju/bus/core/collection/FilterIterator.java b/bus-core/src/main/java/org/aoju/bus/core/collection/FilterIterator.java index d615e0dde6..537374224b 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/collection/FilterIterator.java +++ b/bus-core/src/main/java/org/aoju/bus/core/collection/FilterIterator.java @@ -26,6 +26,7 @@ package org.aoju.bus.core.collection; import org.aoju.bus.core.lang.Assert; +import org.aoju.bus.core.lang.Filter; import java.util.Iterator; import java.util.NoSuchElementException; @@ -41,7 +42,7 @@ public class FilterIterator implements Iterator { private final Iterator iterator; - private final Predicate filter; + private final Filter filter; /** * 下一个元素 @@ -58,7 +59,7 @@ public class FilterIterator implements Iterator { * @param iterator 被包装的{@link Iterator} * @param filter 过滤函数,{@code null}表示不过滤 */ - public FilterIterator(final Iterator iterator, final Predicate filter) { + public FilterIterator(final Iterator iterator, final Filter filter) { this.iterator = Assert.notNull(iterator); this.filter = filter; } @@ -99,7 +100,7 @@ public Iterator getIterator() { * * @return 过滤函数,可能为{@code null} */ - public Predicate getFilter() { + public Filter getFilter() { return filter; } @@ -109,7 +110,7 @@ public Predicate getFilter() { private boolean setNextObject() { while (iterator.hasNext()) { final E object = iterator.next(); - if (null != filter && filter.test(object)) { + if (null == filter || filter.accept(object)) { nextObject = object; nextObjectSet = true; return true; diff --git a/bus-core/src/main/java/org/aoju/bus/core/collection/LineIterator.java b/bus-core/src/main/java/org/aoju/bus/core/collection/LineIterator.java index ed27cffa04..01336f27f5 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/collection/LineIterator.java +++ b/bus-core/src/main/java/org/aoju/bus/core/collection/LineIterator.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.collection; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.toolkit.IoKit; @@ -81,7 +81,7 @@ protected String computeNext() { } } catch (IOException ioe) { close(); - throw new InstrumentException(ioe); + throw new InternalException(ioe); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/compare/FuncCompare.java b/bus-core/src/main/java/org/aoju/bus/core/compare/FuncCompare.java index e8ad1191d6..c5d0d62506 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/compare/FuncCompare.java +++ b/bus-core/src/main/java/org/aoju/bus/core/compare/FuncCompare.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.compare; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.ObjectKit; import java.util.function.Function; @@ -62,7 +62,7 @@ protected int doCompare(T a, T b) { v1 = func.apply(a); v2 = func.apply(b); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } return compare(a, b, v1, v2); diff --git a/bus-core/src/main/java/org/aoju/bus/core/compiler/JavaSourceCompiler.java b/bus-core/src/main/java/org/aoju/bus/core/compiler/JavaSourceCompiler.java index 189f7b7017..a04f38e077 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/compiler/JavaSourceCompiler.java +++ b/bus-core/src/main/java/org/aoju/bus/core/compiler/JavaSourceCompiler.java @@ -1,6 +1,6 @@ package org.aoju.bus.core.compiler; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.resource.FileResource; import org.aoju.bus.core.io.resource.Resource; import org.aoju.bus.core.io.resource.StringResource; @@ -189,7 +189,7 @@ public ClassLoader compile() { IoKit.close(javaFileManager); } //编译失败,收集错误信息 - throw new InstrumentException(DiagnosticCollectors.getMessages(diagnosticCollector)); + throw new InternalException(DiagnosticCollectors.getMessages(diagnosticCollector)); } /** diff --git a/bus-core/src/main/java/org/aoju/bus/core/compress/Deflate.java b/bus-core/src/main/java/org/aoju/bus/core/compress/Deflate.java index ffac6a5e31..c3d4313aa4 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/compress/Deflate.java +++ b/bus-core/src/main/java/org/aoju/bus/core/compress/Deflate.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.compress; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.IoKit; import java.io.Closeable; @@ -103,7 +103,7 @@ public Deflate deflater(int level) { try { ((DeflaterOutputStream) target).finish(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return this; } @@ -120,7 +120,7 @@ public Deflate inflater() { try { ((InflaterOutputStream) target).finish(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return this; } diff --git a/bus-core/src/main/java/org/aoju/bus/core/compress/Gzip.java b/bus-core/src/main/java/org/aoju/bus/core/compress/Gzip.java index 4631e68e71..3380e6e954 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/compress/Gzip.java +++ b/bus-core/src/main/java/org/aoju/bus/core/compress/Gzip.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.compress; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.IoKit; import java.io.Closeable; @@ -90,7 +90,7 @@ public Gzip gzip() { IoKit.copy(source, target); ((GZIPOutputStream) target).finish(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return this; } @@ -106,7 +106,7 @@ public Gzip unGzip() { (GZIPInputStream) source : new GZIPInputStream(source); IoKit.copy(source, target); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return this; } diff --git a/bus-core/src/main/java/org/aoju/bus/core/compress/ZipReader.java b/bus-core/src/main/java/org/aoju/bus/core/compress/ZipReader.java index 796f5192be..e1ea6a52b4 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/compress/ZipReader.java +++ b/bus-core/src/main/java/org/aoju/bus/core/compress/ZipReader.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.compress; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Filter; import org.aoju.bus.core.toolkit.FileKit; import org.aoju.bus.core.toolkit.IoKit; @@ -138,7 +138,7 @@ public InputStream get(String path) { } } } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -150,9 +150,9 @@ public InputStream get(String path) { * * @param outFile 解压到的目录 * @return 解压的目录 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File readTo(File outFile) throws InstrumentException { + public File readTo(File outFile) throws InternalException { return readTo(outFile, null); } @@ -162,9 +162,9 @@ public File readTo(File outFile) throws InstrumentException { * @param outFile 解压到的目录 * @param entryFilter 过滤器,排除不需要的文件 * @return 解压的目录 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File readTo(File outFile, Filter entryFilter) throws InstrumentException { + public File readTo(File outFile, Filter entryFilter) throws InternalException { read((zipEntry) -> { if (null == entryFilter || entryFilter.accept(zipEntry)) { String path = zipEntry.getName(); @@ -194,9 +194,9 @@ public File readTo(File outFile, Filter entryFilter) throws Instrument * * @param consumer {@link ZipEntry}处理器 * @return this - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public ZipReader read(Consumer consumer) throws InstrumentException { + public ZipReader read(Consumer consumer) throws InternalException { if (null != this.zipFile) { readFromZipFile(consumer); } else { @@ -206,7 +206,7 @@ public ZipReader read(Consumer consumer) throws InstrumentException { } @Override - public void close() throws InstrumentException { + public void close() throws InternalException { if (null != this.zipFile) { IoKit.close(this.zipFile); } else { @@ -230,16 +230,16 @@ private void readFromZipFile(Consumer consumer) { * 读取并处理Zip流中的每一个{@link ZipEntry} * * @param consumer {@link ZipEntry}处理器 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - private void readFromStream(Consumer consumer) throws InstrumentException { + private void readFromStream(Consumer consumer) throws InternalException { try { ZipEntry zipEntry; while (null != (zipEntry = in.getNextEntry())) { consumer.accept(zipEntry); } } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/compress/ZipWriter.java b/bus-core/src/main/java/org/aoju/bus/core/compress/ZipWriter.java index ca1a186ef8..343383a2f9 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/compress/ZipWriter.java +++ b/bus-core/src/main/java/org/aoju/bus/core/compress/ZipWriter.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.compress; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.resource.Resource; import org.aoju.bus.core.lang.Symbol; import org.aoju.bus.core.toolkit.ArrayKit; @@ -160,9 +160,9 @@ public ZipOutputStream getOut() { * * @param resources 需要压缩的资源,资源的路径为{@link Resource#getName()} * @return this - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public ZipWriter add(Resource... resources) throws InstrumentException { + public ZipWriter add(Resource... resources) throws InternalException { for (Resource resource : resources) { if (null != resource) { add(resource.getName(), resource.getStream()); @@ -178,9 +178,9 @@ public ZipWriter add(Resource... resources) throws InstrumentException { * @param path 压缩的路径, {@code null}和""表示根目录下 * @param in 需要压缩的输入流,使用完后自动关闭,{@code null}表示加入空目录 * @return this - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public ZipWriter add(String path, InputStream in) throws InstrumentException { + public ZipWriter add(String path, InputStream in) throws InternalException { path = StringKit.nullToEmpty(path); if (null == in) { // 空目录需要检查路径规范性,目录以"/"结尾 @@ -200,9 +200,9 @@ public ZipWriter add(String path, InputStream in) throws InstrumentException { * @param paths 流数据在压缩文件中的路径或文件名 * @param ins 要压缩的源,添加完成后自动关闭流 * @return 压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public ZipWriter add(String[] paths, InputStream[] ins) throws InstrumentException { + public ZipWriter add(String[] paths, InputStream[] ins) throws InternalException { if (ArrayKit.isEmpty(paths) || ArrayKit.isEmpty(ins)) { throw new IllegalArgumentException("Paths or ins is empty !"); } @@ -224,9 +224,9 @@ public ZipWriter add(String[] paths, InputStream[] ins) throws InstrumentExcepti * @param filter 文件过滤器,通过实现此接口,自定义要过滤的文件(过滤掉哪些文件或文件夹不加入压缩),{@code null}表示不过滤 * @param files 要压缩的源文件或目录。如果压缩一个文件,则为该文件的全路径;如果压缩一个目录,则为该目录的顶层目录路径 * @return this - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public ZipWriter add(boolean withSrcDir, FileFilter filter, File... files) throws InstrumentException { + public ZipWriter add(boolean withSrcDir, FileFilter filter, File... files) throws InternalException { for (File file : files) { // 如果只是压缩一个文件,则需要截取该文件的父目录 String srcRootDir; @@ -237,7 +237,7 @@ public ZipWriter add(boolean withSrcDir, FileFilter filter, File... files) throw srcRootDir = file.getCanonicalFile().getParentFile().getCanonicalPath(); } } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } _add(file, srcRootDir, filter); @@ -246,11 +246,11 @@ public ZipWriter add(boolean withSrcDir, FileFilter filter, File... files) throw } @Override - public void close() throws InstrumentException { + public void close() throws InternalException { try { out.finish(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(this.out); } @@ -264,9 +264,9 @@ public void close() throws InstrumentException { * @param srcRootDir 被压缩的文件夹根目录 * @param file 当前递归压缩的文件或目录对象 * @param filter 文件过滤器,通过实现此接口,自定义要过滤的文件(过滤掉哪些文件或文件夹不加入压缩),{@code null}表示不过滤 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - private ZipWriter _add(File file, String srcRootDir, FileFilter filter) throws InstrumentException { + private ZipWriter _add(File file, String srcRootDir, FileFilter filter) throws InternalException { if (null == file || (null != filter && false == filter.accept(file))) { return this; } @@ -298,9 +298,9 @@ private ZipWriter _add(File file, String srcRootDir, FileFilter filter) throws I * * @param path 压缩的路径, {@code null}和""表示根目录下 * @param in 需要压缩的输入流,使用完后自动关闭,{@code null}表示加入空目录 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - private ZipWriter putEntry(String path, InputStream in) throws InstrumentException { + private ZipWriter putEntry(String path, InputStream in) throws InternalException { try { out.putNextEntry(new ZipEntry(path)); if (null != in) { @@ -308,7 +308,7 @@ private ZipWriter putEntry(String path, InputStream in) throws InstrumentExcepti } out.closeEntry(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(in); } diff --git a/bus-core/src/main/java/org/aoju/bus/core/convert/ConverterRegistry.java b/bus-core/src/main/java/org/aoju/bus/core/convert/ConverterRegistry.java index 3f52f1eab8..43d637f7c8 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/convert/ConverterRegistry.java +++ b/bus-core/src/main/java/org/aoju/bus/core/convert/ConverterRegistry.java @@ -61,11 +61,11 @@ public class ConverterRegistry { /** * 默认类型转换器 */ - private Map> defaultConverterMap; + private Map> defaultMap; /** * 用户自定义类型转换器 */ - private volatile Map> customConverterMap; + private volatile Map> customMap; public ConverterRegistry() { defaultConverter(); @@ -100,14 +100,14 @@ public ConverterRegistry putCustom(Type type, Class> conv * @return {@link ConverterRegistry} */ public ConverterRegistry putCustom(Type type, Converter converter) { - if (null == customConverterMap) { + if (null == customMap) { synchronized (this) { - if (null == customConverterMap) { - customConverterMap = new ConcurrentHashMap<>(); + if (null == customMap) { + customMap = new ConcurrentHashMap<>(); } } } - customConverterMap.put(type, converter); + customMap.put(type, converter); return this; } @@ -143,7 +143,7 @@ public Converter getConverter(Type type, boolean isCustomFirst) { * @return 转换器 */ public Converter getDefaultConverter(Type type) { - return (null == defaultConverterMap) ? null : (Converter) defaultConverterMap.get(type); + return (null == defaultMap) ? null : (Converter) defaultMap.get(type); } /** @@ -154,7 +154,7 @@ public Converter getDefaultConverter(Type type) { * @return 转换器 */ public Converter getCustomConverter(Type type) { - return (null == customConverterMap) ? null : (Converter) customConverterMap.get(type); + return (null == customMap) ? null : (Converter) customMap.get(type); } /** @@ -307,81 +307,84 @@ private T convertSpecial(Type type, Class rowType, Object value, T defaul * @return 转换器 */ private ConverterRegistry defaultConverter() { - defaultConverterMap = new ConcurrentHashMap<>(); + defaultMap = new ConcurrentHashMap<>(); // 原始类型转换器 - defaultConverterMap.put(int.class, new PrimitiveConverter(int.class)); - defaultConverterMap.put(long.class, new PrimitiveConverter(long.class)); - defaultConverterMap.put(byte.class, new PrimitiveConverter(byte.class)); - defaultConverterMap.put(short.class, new PrimitiveConverter(short.class)); - defaultConverterMap.put(float.class, new PrimitiveConverter(float.class)); - defaultConverterMap.put(double.class, new PrimitiveConverter(double.class)); - defaultConverterMap.put(char.class, new PrimitiveConverter(char.class)); - defaultConverterMap.put(boolean.class, new PrimitiveConverter(boolean.class)); + defaultMap.put(int.class, new PrimitiveConverter(int.class)); + defaultMap.put(long.class, new PrimitiveConverter(long.class)); + defaultMap.put(byte.class, new PrimitiveConverter(byte.class)); + defaultMap.put(short.class, new PrimitiveConverter(short.class)); + defaultMap.put(float.class, new PrimitiveConverter(float.class)); + defaultMap.put(double.class, new PrimitiveConverter(double.class)); + defaultMap.put(char.class, new PrimitiveConverter(char.class)); + defaultMap.put(boolean.class, new PrimitiveConverter(boolean.class)); // 包装类转换器 - defaultConverterMap.put(Number.class, new NumberConverter()); - defaultConverterMap.put(Integer.class, new NumberConverter(Integer.class)); - defaultConverterMap.put(AtomicInteger.class, new NumberConverter(AtomicInteger.class)); - defaultConverterMap.put(Long.class, new NumberConverter(Long.class)); - defaultConverterMap.put(LongAdder.class, new NumberConverter(LongAdder.class)); - defaultConverterMap.put(AtomicLong.class, new NumberConverter(AtomicLong.class)); - defaultConverterMap.put(Byte.class, new NumberConverter(Byte.class)); - defaultConverterMap.put(Short.class, new NumberConverter(Short.class)); - defaultConverterMap.put(Float.class, new NumberConverter(Float.class)); - defaultConverterMap.put(Double.class, new NumberConverter(Double.class)); - defaultConverterMap.put(DoubleAdder.class, new NumberConverter(DoubleAdder.class)); - defaultConverterMap.put(Character.class, new CharacterConverter()); - defaultConverterMap.put(Boolean.class, new BooleanConverter()); - defaultConverterMap.put(AtomicBoolean.class, new AtomicBooleanConverter()); - defaultConverterMap.put(BigDecimal.class, new NumberConverter(BigDecimal.class)); - defaultConverterMap.put(BigInteger.class, new NumberConverter(BigInteger.class)); - defaultConverterMap.put(CharSequence.class, new StringConverter()); - defaultConverterMap.put(String.class, new StringConverter()); + defaultMap.put(Number.class, new NumberConverter()); + defaultMap.put(Integer.class, new NumberConverter(Integer.class)); + defaultMap.put(AtomicInteger.class, new NumberConverter(AtomicInteger.class)); + defaultMap.put(Long.class, new NumberConverter(Long.class)); + defaultMap.put(LongAdder.class, new NumberConverter(LongAdder.class)); + defaultMap.put(AtomicLong.class, new NumberConverter(AtomicLong.class)); + defaultMap.put(Byte.class, new NumberConverter(Byte.class)); + defaultMap.put(Short.class, new NumberConverter(Short.class)); + defaultMap.put(Float.class, new NumberConverter(Float.class)); + defaultMap.put(Double.class, new NumberConverter(Double.class)); + defaultMap.put(DoubleAdder.class, new NumberConverter(DoubleAdder.class)); + defaultMap.put(Character.class, new CharacterConverter()); + defaultMap.put(Boolean.class, new BooleanConverter()); + defaultMap.put(AtomicBoolean.class, new AtomicBooleanConverter()); + defaultMap.put(BigDecimal.class, new NumberConverter(BigDecimal.class)); + defaultMap.put(BigInteger.class, new NumberConverter(BigInteger.class)); + defaultMap.put(CharSequence.class, new StringConverter()); + defaultMap.put(String.class, new StringConverter()); // URI and URL - defaultConverterMap.put(URI.class, new URIConverter()); - defaultConverterMap.put(URL.class, new URLConverter()); + defaultMap.put(URI.class, new URIConverter()); + defaultMap.put(URL.class, new URLConverter()); // 日期时间 - defaultConverterMap.put(Calendar.class, new CalendarConverter()); - defaultConverterMap.put(java.util.Date.class, new DateConverter(java.util.Date.class)); - defaultConverterMap.put(DateTime.class, new DateConverter(DateTime.class)); - defaultConverterMap.put(java.sql.Date.class, new DateConverter(java.sql.Date.class)); - defaultConverterMap.put(java.sql.Time.class, new DateConverter(java.sql.Time.class)); - defaultConverterMap.put(java.sql.Timestamp.class, new DateConverter(java.sql.Timestamp.class)); + defaultMap.put(Calendar.class, new CalendarConverter()); + defaultMap.put(java.util.Date.class, new DateConverter(java.util.Date.class)); + defaultMap.put(DateTime.class, new DateConverter(DateTime.class)); + defaultMap.put(java.sql.Date.class, new DateConverter(java.sql.Date.class)); + defaultMap.put(java.sql.Time.class, new DateConverter(java.sql.Time.class)); + defaultMap.put(java.sql.Timestamp.class, new DateConverter(java.sql.Timestamp.class)); // 日期时间 JDK8+(since 5.0.0) - defaultConverterMap.put(TemporalAccessor.class, new TemporalConverter(Instant.class)); - defaultConverterMap.put(Instant.class, new TemporalConverter(Instant.class)); - defaultConverterMap.put(LocalDateTime.class, new TemporalConverter(LocalDateTime.class)); - defaultConverterMap.put(LocalDate.class, new TemporalConverter(LocalDate.class)); - defaultConverterMap.put(LocalTime.class, new TemporalConverter(LocalTime.class)); - defaultConverterMap.put(ZonedDateTime.class, new TemporalConverter(ZonedDateTime.class)); - defaultConverterMap.put(OffsetDateTime.class, new TemporalConverter(OffsetDateTime.class)); - defaultConverterMap.put(OffsetTime.class, new TemporalConverter(OffsetTime.class)); - defaultConverterMap.put(Period.class, new PeriodConverter()); - defaultConverterMap.put(Duration.class, new DurationConverter()); + defaultMap.put(TemporalAccessor.class, new TemporalConverter(Instant.class)); + defaultMap.put(Instant.class, new TemporalConverter(Instant.class)); + defaultMap.put(LocalDateTime.class, new TemporalConverter(LocalDateTime.class)); + defaultMap.put(LocalDate.class, new TemporalConverter(LocalDate.class)); + defaultMap.put(LocalTime.class, new TemporalConverter(LocalTime.class)); + defaultMap.put(ZonedDateTime.class, new TemporalConverter(ZonedDateTime.class)); + defaultMap.put(OffsetDateTime.class, new TemporalConverter(OffsetDateTime.class)); + defaultMap.put(OffsetTime.class, new TemporalConverter(OffsetTime.class)); + defaultMap.put(DayOfWeek.class, new TemporalConverter(DayOfWeek.class)); + defaultMap.put(Month.class, new TemporalConverter(Month.class)); + defaultMap.put(MonthDay.class, new TemporalConverter(MonthDay.class)); + defaultMap.put(Period.class, new PeriodConverter()); + defaultMap.put(Duration.class, new DurationConverter()); // Reference - defaultConverterMap.put(WeakReference.class, new ReferenceConverter(WeakReference.class)); - defaultConverterMap.put(SoftReference.class, new ReferenceConverter(SoftReference.class)); - defaultConverterMap.put(AtomicReference.class, new AtomicReferenceConverter()); + defaultMap.put(WeakReference.class, new ReferenceConverter(WeakReference.class)); + defaultMap.put(SoftReference.class, new ReferenceConverter(SoftReference.class)); + defaultMap.put(AtomicReference.class, new AtomicReferenceConverter()); - defaultConverterMap.put(AtomicIntegerArray.class, new AtomicIntegerArrayConverter()); - defaultConverterMap.put(AtomicLongArray.class, new AtomicLongArrayConverter()); + defaultMap.put(AtomicIntegerArray.class, new AtomicIntegerArrayConverter()); + defaultMap.put(AtomicLongArray.class, new AtomicLongArrayConverter()); // 其它类型 - defaultConverterMap.put(Class.class, new ClassConverter()); - defaultConverterMap.put(TimeZone.class, new TimeZoneConverter()); - defaultConverterMap.put(Locale.class, new LocaleConverter()); - defaultConverterMap.put(Charset.class, new CharsetConverter()); - defaultConverterMap.put(Path.class, new PathConverter()); - defaultConverterMap.put(Currency.class, new CurrencyConverter()); - defaultConverterMap.put(UUID.class, new UUIDConverter()); - defaultConverterMap.put(StackTraceElement.class, new StackTraceConverter()); - defaultConverterMap.put(Optional.class, new OptionalConverter()); - defaultConverterMap.put(Optional.class, new OptionalConverter()); + defaultMap.put(Class.class, new ClassConverter()); + defaultMap.put(TimeZone.class, new TimeZoneConverter()); + defaultMap.put(Locale.class, new LocaleConverter()); + defaultMap.put(Charset.class, new CharsetConverter()); + defaultMap.put(Path.class, new PathConverter()); + defaultMap.put(Currency.class, new CurrencyConverter()); + defaultMap.put(UUID.class, new UUIDConverter()); + defaultMap.put(StackTraceElement.class, new StackTraceConverter()); + defaultMap.put(Optional.class, new OptionalConverter()); + defaultMap.put(Optional.class, new OptionalConverter()); return this; } diff --git a/bus-core/src/main/java/org/aoju/bus/core/convert/DateConverter.java b/bus-core/src/main/java/org/aoju/bus/core/convert/DateConverter.java index 0a9d479e6b..d5a4a7d1d1 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/convert/DateConverter.java +++ b/bus-core/src/main/java/org/aoju/bus/core/convert/DateConverter.java @@ -26,7 +26,7 @@ package org.aoju.bus.core.convert; import org.aoju.bus.core.date.DateTime; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.DateKit; import org.aoju.bus.core.toolkit.StringKit; @@ -110,7 +110,7 @@ protected Date convertInternal(Object value) { return wrap(dateTime); } } - throw new InstrumentException("Can not convert {}:[{}] to {}", value.getClass().getName(), value, this.targetType.getName()); + throw new InternalException("Can not convert {}:[{}] to {}", value.getClass().getName(), value, this.targetType.getName()); } @Override diff --git a/bus-core/src/main/java/org/aoju/bus/core/convert/TemporalConverter.java b/bus-core/src/main/java/org/aoju/bus/core/convert/TemporalConverter.java index 98a489b39a..f9f825c21c 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/convert/TemporalConverter.java +++ b/bus-core/src/main/java/org/aoju/bus/core/convert/TemporalConverter.java @@ -31,6 +31,8 @@ import org.aoju.bus.core.toolkit.StringKit; import java.time.*; +import java.time.chrono.Era; +import java.time.chrono.IsoEra; import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAccessor; import java.util.Calendar; @@ -139,6 +141,17 @@ private TemporalAccessor parseFromCharSequence(CharSequence value) { if (StringKit.isBlank(value)) { return null; } + + if (DayOfWeek.class.equals(this.targetType)) { + return DayOfWeek.valueOf(StringKit.toString(value)); + } else if (Month.class.equals(this.targetType)) { + return Month.valueOf(StringKit.toString(value)); + } else if (Era.class.equals(this.targetType)) { + return IsoEra.valueOf(StringKit.toString(value)); + } else if (MonthDay.class.equals(this.targetType)) { + return MonthDay.parse(value); + } + final Instant instant; ZoneId zoneId; if (null != this.format) { @@ -160,6 +173,13 @@ private TemporalAccessor parseFromCharSequence(CharSequence value) { * @return java.time中的对象 */ private TemporalAccessor parseFromLong(Long time) { + if (DayOfWeek.class.equals(this.targetType)) { + return DayOfWeek.of(Math.toIntExact(time)); + } else if (Month.class.equals(this.targetType)) { + return Month.of(Math.toIntExact(time)); + } else if (Era.class.equals(this.targetType)) { + return IsoEra.of(Math.toIntExact(time)); + } return parseFromInstant(Instant.ofEpochMilli(time), null); } @@ -170,6 +190,14 @@ private TemporalAccessor parseFromLong(Long time) { * @return java.time中的对象 */ private TemporalAccessor parseFromTemporalAccessor(TemporalAccessor temporalAccessor) { + if (DayOfWeek.class.equals(this.targetType)) { + return DayOfWeek.from(temporalAccessor); + } else if (Month.class.equals(this.targetType)) { + return Month.from(temporalAccessor); + } else if (MonthDay.class.equals(this.targetType)) { + return MonthDay.from(temporalAccessor); + } + TemporalAccessor result = null; if (temporalAccessor instanceof LocalDateTime) { result = parseFromLocalDateTime((LocalDateTime) temporalAccessor); diff --git a/bus-core/src/main/java/org/aoju/bus/core/date/Almanac.java b/bus-core/src/main/java/org/aoju/bus/core/date/Almanac.java index 75722c5099..e716234a27 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/date/Almanac.java +++ b/bus-core/src/main/java/org/aoju/bus/core/date/Almanac.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.date; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Fields; import org.aoju.bus.core.lang.Normal; import org.aoju.bus.core.lang.RegEx; @@ -121,7 +121,7 @@ public static List getYear(String startDate, String endDate) { list.add(text); } } catch (ParseException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return list; } @@ -236,7 +236,7 @@ public static Map getQuarter(int type, + Symbol.MINUS + getMonthOfQuarter(1, Integer.parseInt(map.get(endWkey)))); } catch (ParseException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return map; } @@ -281,7 +281,7 @@ public static List getQuarter(String StartDate, } while (true); } catch (ParseException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -364,7 +364,7 @@ public static List getMonth(String startDate, String endDate) { list.add(text); } } catch (ParseException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return list; } @@ -416,7 +416,7 @@ public static Map getMonth(int type, map.put(beginkey, sdf.format(calBegin.getTime())); map.put(endkey, sdf.format(calEnd.getTime())); } catch (ParseException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return map; } @@ -741,7 +741,7 @@ public static List getWeek(String begin, String end, String startw, Stri beginww++; } while (beginY <= endY); } catch (ParseException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return lDate; } @@ -757,7 +757,7 @@ public static int getWeek(String year) { try { calendar.setTime(Fields.PURE_DATETIME_FORMAT.parse(year + "-12-31")); } catch (ParseException e) { - throw new InstrumentException(e); + throw new InternalException(e); } calendar.setFirstDayOfWeek(Calendar.MONDAY); int week = calendar.get(Calendar.WEEK_OF_YEAR); @@ -1455,7 +1455,7 @@ public static Map getLast(int type, map.put(beginkey, Fields.PURE_DATETIME_FORMAT.format(calBegin.getTime())); map.put(endkey, Fields.PURE_DATETIME_FORMAT.format(calEnd.getTime())); } catch (ParseException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return map; } @@ -1485,7 +1485,7 @@ public static List getLast(String begin, String end) { lDate.add(Fields.PURE_DATETIME_FORMAT.format(calBegin.getTime())); } } catch (ParseException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return lDate; } @@ -1558,7 +1558,7 @@ public static Map getLast(int type, String beginkey, map.put(beginkey, Fields.PURE_DATETIME_FORMAT.format(calBegin.getTime())); map.put(endkey, Fields.PURE_DATETIME_FORMAT.format(calEnd.getTime())); } catch (ParseException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return map; } @@ -1591,7 +1591,7 @@ public static Map getLast(String beginkey, map.put(beginkey, Fields.NORM_YEAR_FORMAT.format(calBegin.getTime())); map.put(endkey, Fields.NORM_YEAR_FORMAT.format(calEnd.getTime())); } catch (ParseException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return map; } diff --git a/bus-core/src/main/java/org/aoju/bus/core/date/DateTime.java b/bus-core/src/main/java/org/aoju/bus/core/date/DateTime.java index 81a65a8c0c..fa0d9caa97 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/date/DateTime.java +++ b/bus-core/src/main/java/org/aoju/bus/core/date/DateTime.java @@ -28,7 +28,7 @@ import org.aoju.bus.core.date.formatter.DateParser; import org.aoju.bus.core.date.formatter.DatePrinter; import org.aoju.bus.core.date.formatter.FormatBuilder; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Fields; import org.aoju.bus.core.lang.System; @@ -303,7 +303,7 @@ private static Date parse(CharSequence dateStr, DateFormat dateFormat) { } else { pattern = dateFormat.toString(); } - throw new InstrumentException(StringKit.format("Parse [{}] with format [{}] error!", dateStr, pattern), e); + throw new InternalException(StringKit.format("Parse [{}] with format [{}] error!", dateStr, pattern), e); } } @@ -320,7 +320,7 @@ private static Calendar parse(CharSequence dateStr, DateParser parser, boolean l final Calendar calendar = Formatter.parse(dateStr, lenient, parser); if (null == calendar) { - throw new InstrumentException("Parse [{}] with format [{}] error!", dateStr, parser.getPattern()); + throw new InternalException("Parse [{}] with format [{}] error!", dateStr, parser.getPattern()); } calendar.setFirstDayOfWeek(Fields.Week.Mon.getKey()); return calendar; @@ -465,7 +465,7 @@ public void setTime(long time) { if (mutable) { super.setTime(time); } else { - throw new InstrumentException("This is not a mutable object !"); + throw new InternalException("This is not a mutable object !"); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/date/Formatter.java b/bus-core/src/main/java/org/aoju/bus/core/date/Formatter.java index 917b3b38c7..40791ddcd1 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/date/Formatter.java +++ b/bus-core/src/main/java/org/aoju/bus/core/date/Formatter.java @@ -27,7 +27,7 @@ import org.aoju.bus.core.convert.NumberFormatter; import org.aoju.bus.core.date.formatter.*; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Fields; import org.aoju.bus.core.lang.Normal; import org.aoju.bus.core.lang.RegEx; @@ -39,6 +39,7 @@ import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.time.*; +import java.time.chrono.Era; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.temporal.TemporalAccessor; @@ -186,7 +187,7 @@ public static long format(String date) { try { return Fields.NORM_DATETIME_FORMAT.parse(date).getTime(); } catch (ParseException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -223,7 +224,7 @@ public static long format(String date, String format) { try { return new SimpleDateFormat(format).parse(date).getTime(); } catch (ParseException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -308,6 +309,13 @@ public static String format(TemporalAccessor time, String format) { return time.toString(); } + if (time instanceof DayOfWeek + || time instanceof Month + || time instanceof Era + || time instanceof MonthDay) { + return time.toString(); + } + final DateTimeFormatter formatter = StringKit.isBlank(format) ? null : DateTimeFormatter.ofPattern(format); @@ -571,7 +579,7 @@ public static DateTime parse(CharSequence text) { } // 没有更多匹配的时间格式 - throw new InstrumentException("No format fit for date String [{}] !", dateStr); + throw new InternalException("No format fit for date String [{}] !", dateStr); } /** @@ -696,7 +704,7 @@ public static Calendar parse(String text, Locale locale, boolean lenient, String } pos.setIndex(0); } - throw new InstrumentException("Unable to parse the date: {}", text); + throw new InternalException("Unable to parse the date: {}", text); } /** @@ -828,7 +836,7 @@ public static DateTime parseUTC(String text) { text = text.replace(Symbol.SPACE + Symbol.PLUS, Symbol.PLUS); final String zoneOffset = StringKit.subAfter(text, Symbol.C_PLUS, true); if (StringKit.isBlank(zoneOffset)) { - throw new InstrumentException("Invalid format: [{}]", text); + throw new InternalException("Invalid format: [{}]", text); } if (false == StringKit.contains(zoneOffset, Symbol.C_COLON)) { // +0800转换为+08:00 @@ -854,7 +862,7 @@ public static DateTime parseUTC(String text) { } // 没有更多匹配的时间格式 - throw new InstrumentException("No format fit for date String [{}] !", text); + throw new InternalException("No format fit for date String [{}] !", text); } /** @@ -916,7 +924,7 @@ public static Calendar parseByPatterns(String text, Locale locale, boolean lenie } pos.setIndex(0); } - throw new InstrumentException("Unable to parse the date: {}", text); + throw new InternalException("Unable to parse the date: {}", text); } /** diff --git a/bus-core/src/main/java/org/aoju/bus/core/date/formatter/FastDatePrinter.java b/bus-core/src/main/java/org/aoju/bus/core/date/formatter/FastDatePrinter.java index bd66582101..11349a9ac4 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/date/formatter/FastDatePrinter.java +++ b/bus-core/src/main/java/org/aoju/bus/core/date/formatter/FastDatePrinter.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.date.formatter; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Symbol; import java.io.IOException; @@ -484,7 +484,7 @@ private B applyRules(final Calendar calendar, final B buf rule.appendTo(buf, calendar); } } catch (final IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return buf; } diff --git a/bus-core/src/main/java/org/aoju/bus/core/exception/InstrumentException.java b/bus-core/src/main/java/org/aoju/bus/core/exception/InternalException.java similarity index 84% rename from bus-core/src/main/java/org/aoju/bus/core/exception/InstrumentException.java rename to bus-core/src/main/java/org/aoju/bus/core/exception/InternalException.java index c6ae8d310a..197e448576 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/exception/InstrumentException.java +++ b/bus-core/src/main/java/org/aoju/bus/core/exception/InternalException.java @@ -31,35 +31,35 @@ * @author Kimi Liu * @since Java 17+ */ -public class InstrumentException extends UncheckedException { +public class InternalException extends UncheckedException { private static final long serialVersionUID = 1L; - public InstrumentException() { + public InternalException() { super(); } - public InstrumentException(Throwable cause) { + public InternalException(Throwable cause) { super(cause); } - public InstrumentException(String format, Object... args) { + public InternalException(String format, Object... args) { super(format, args); } - public InstrumentException(String message) { + public InternalException(String message) { super(message); } - public InstrumentException(String message, Throwable cause) { + public InternalException(String message, Throwable cause) { super(message, cause); } - public InstrumentException(String errcode, String errmsg) { + public InternalException(String errcode, String errmsg) { super(errcode, errmsg); } - public InstrumentException(Throwable cause, String format, Object... args) { + public InternalException(Throwable cause, String format, Object... args) { super(String.format(format, args), cause); } diff --git a/bus-core/src/main/java/org/aoju/bus/core/exception/TokenExpiredException.java b/bus-core/src/main/java/org/aoju/bus/core/exception/TokenException.java similarity index 84% rename from bus-core/src/main/java/org/aoju/bus/core/exception/TokenExpiredException.java rename to bus-core/src/main/java/org/aoju/bus/core/exception/TokenException.java index d9ef7aef39..a3d421a44a 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/exception/TokenExpiredException.java +++ b/bus-core/src/main/java/org/aoju/bus/core/exception/TokenException.java @@ -26,36 +26,36 @@ package org.aoju.bus.core.exception; /** - * 自定义异常: 令牌过期 + * 自定义异常: 令牌过期/其他 * * @author Kimi Liu * @since Java 17+ */ -public class TokenExpiredException extends UncheckedException { +public class TokenException extends UncheckedException { private static final long serialVersionUID = 1L; - public TokenExpiredException() { + public TokenException() { super(); } - public TokenExpiredException(Throwable cause) { + public TokenException(Throwable cause) { super(cause); } - public TokenExpiredException(String format, Object... args) { + public TokenException(String format, Object... args) { super(format, args); } - public TokenExpiredException(String message) { + public TokenException(String message) { super(message); } - public TokenExpiredException(String message, Throwable cause) { + public TokenException(String message, Throwable cause) { super(message, cause); } - public TokenExpiredException(String errcode, String errmsg) { + public TokenException(String errcode, String errmsg) { super(errcode, errmsg); } diff --git a/bus-core/src/main/java/org/aoju/bus/core/image/Images.java b/bus-core/src/main/java/org/aoju/bus/core/image/Images.java index 4b02cde219..3674e9f727 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/image/Images.java +++ b/bus-core/src/main/java/org/aoju/bus/core/image/Images.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.image; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.image.element.AbstractElement; import org.aoju.bus.core.image.element.ImageElement; import org.aoju.bus.core.image.element.RectangleElement; @@ -190,7 +190,7 @@ public Images(BufferedImage srcImage, String imageUrl, String fileType) { this.canvasWidth = imageElement.getImage().getWidth(); this.canvasHeight = imageElement.getImage().getHeight(); } catch (Exception e) { - throw new InstrumentException(e.getMessage()); + throw new InternalException(e.getMessage()); } } else { imageElement = new ImageElement(srcImage, 0, 0); @@ -1063,9 +1063,9 @@ public java.awt.Image getImg() { * * @param out 写出到的目标流 * @return 是否成功写出, 如果返回false表示未找到合适的Writer - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public boolean write(OutputStream out) throws InstrumentException { + public boolean write(OutputStream out) throws InternalException { return write(ImageKit.getImageOutputStream(out)); } @@ -1075,9 +1075,9 @@ public boolean write(OutputStream out) throws InstrumentException { * * @param targetImageStream 写出到的目标流 * @return 是否成功写出, 如果返回false表示未找到合适的Writer - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public boolean write(ImageOutputStream targetImageStream) throws InstrumentException { + public boolean write(ImageOutputStream targetImageStream) throws InternalException { Assert.notBlank(this.fileType, "Target image type is blank !"); Assert.notNull(targetImageStream, "Target output stream is null !"); @@ -1092,9 +1092,9 @@ public boolean write(ImageOutputStream targetImageStream) throws InstrumentExcep * * @param targetFile 目标文件 * @return 是否成功写出, 如果返回false表示未找到合适的Writer - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public boolean write(File targetFile) throws InstrumentException { + public boolean write(File targetFile) throws InternalException { final String formatName = FileKit.getSuffix(targetFile); if (StringKit.isNotBlank(formatName)) { this.fileType = formatName; diff --git a/bus-core/src/main/java/org/aoju/bus/core/instance/InstanceFactory.java b/bus-core/src/main/java/org/aoju/bus/core/instance/InstanceFactory.java index 00efa1872d..735578ca8a 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/instance/InstanceFactory.java +++ b/bus-core/src/main/java/org/aoju/bus/core/instance/InstanceFactory.java @@ -26,7 +26,7 @@ package org.aoju.bus.core.instance; import org.aoju.bus.core.annotation.ThreadSafe; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Symbol; import org.aoju.bus.core.toolkit.ObjectKit; @@ -125,7 +125,7 @@ public T multiple(Class clazz) { try { return clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/copier/ChannelCopier.java b/bus-core/src/main/java/org/aoju/bus/core/io/copier/ChannelCopier.java index 9e6a9206e0..83f22d8a09 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/io/copier/ChannelCopier.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/copier/ChannelCopier.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.copier; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.Progress; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.toolkit.IoKit; @@ -95,7 +95,7 @@ public long copy(ReadableByteChannel source, WritableByteChannel target) { try { size = doCopy(source, target, ByteBuffer.allocate(bufferSize(this.count)), progress); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (null != progress) { diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/copier/ReaderWriterCopier.java b/bus-core/src/main/java/org/aoju/bus/core/io/copier/ReaderWriterCopier.java index f0a33341a6..d73e03168e 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/io/copier/ReaderWriterCopier.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/copier/ReaderWriterCopier.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.copier; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.Progress; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.toolkit.IoKit; @@ -91,7 +91,7 @@ public long copy(Reader source, Writer target) { size = doCopy(source, target, new char[bufferSize(this.count)], progress); target.flush(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (null != progress) { diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/copier/StreamCopier.java b/bus-core/src/main/java/org/aoju/bus/core/io/copier/StreamCopier.java index 1283033850..b9f67b0fad 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/io/copier/StreamCopier.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/copier/StreamCopier.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.copier; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.Progress; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.toolkit.IoKit; @@ -93,7 +93,7 @@ public long copy(InputStream source, OutputStream target) { size = doCopy(source, target, new byte[bufferSize(this.count)], progress); target.flush(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (null != progress) { diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/file/FileCopier.java b/bus-core/src/main/java/org/aoju/bus/core/io/file/FileCopier.java index fd24d8ad4f..fad69fb95a 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/io/file/FileCopier.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/file/FileCopier.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.file; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.copier.Duplicate; import org.aoju.bus.core.toolkit.ArrayKit; @@ -197,26 +197,26 @@ public FileCopier setOnlyCopyFile(boolean isOnlyCopyFile) { * * * @return 拷贝后目标的文件或目录 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ @Override - public File copy() throws InstrumentException { + public File copy() throws InternalException { final File src = this.src; final File dest = this.dest; // check Assert.notNull(src, "Source File is null !"); if (false == src.exists()) { - throw new InstrumentException("File not exist: " + src); + throw new InternalException("File not exist: " + src); } Assert.notNull(dest, "Destination File or directory is null !"); if (FileKit.equals(src, dest)) { - throw new InstrumentException("Files '{" + src + "}' and '{" + dest + "}' are equal"); + throw new InternalException("Files '{" + src + "}' and '{" + dest + "}' are equal"); } if (src.isDirectory()) {// 复制目录 if (dest.exists() && false == dest.isDirectory()) { //源为目录,目标为文件,抛出IO异常 - throw new InstrumentException("Src is a directory but dest is a file!"); + throw new InternalException("Src is a directory but dest is a file!"); } final File subTarget = isCopyContentIfDir ? dest : FileKit.mkdir(FileKit.file(dest, src.getName())); internalCopyDirContent(src, subTarget); @@ -232,9 +232,9 @@ public File copy() throws InstrumentException { * * @param src 源目录 * @param dest 目标目录 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - private void internalCopyDirContent(File src, File dest) throws InstrumentException { + private void internalCopyDirContent(File src, File dest) throws InternalException { if (null != predicate && false == predicate.test(src)) { //被过滤的目录跳过 return; @@ -244,7 +244,7 @@ private void internalCopyDirContent(File src, File dest) throws InstrumentExcept //目标为不存在路径,创建为目录 dest.mkdirs(); } else if (false == dest.isDirectory()) { - throw new InstrumentException(StringKit.format("Src [{}] is a directory but dest [{}] is a file!", src.getPath(), dest.getPath())); + throw new InternalException(StringKit.format("Src [{}] is a directory but dest [{}] is a file!", src.getPath(), dest.getPath())); } final String[] files = src.list(); @@ -274,9 +274,9 @@ private void internalCopyDirContent(File src, File dest) throws InstrumentExcept * * @param src 源文件,必须为文件 * @param dest 目标文件,如果非覆盖模式必须为目录 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - private void internalCopyFile(File src, File dest) throws InstrumentException { + private void internalCopyFile(File src, File dest) throws InternalException { if (null != predicate && false == predicate.test(src)) { // 被过滤的文件跳过 return; @@ -309,7 +309,7 @@ private void internalCopyFile(File src, File dest) throws InstrumentException { try { Files.copy(src.toPath(), dest.toPath(), optionList.toArray(new CopyOption[0])); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/file/FileReader.java b/bus-core/src/main/java/org/aoju/bus/core/io/file/FileReader.java index 9ed178812e..dd00437063 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/io/file/FileReader.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/file/FileReader.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.file; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.LineHandler; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.toolkit.FileKit; @@ -132,12 +132,12 @@ public static FileReader create(File file) { * 文件的长度不能超过 {@link Integer#MAX_VALUE} * * @return 字节码 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public byte[] readBytes() throws InstrumentException { + public byte[] readBytes() throws InternalException { long len = file.length(); if (len >= Integer.MAX_VALUE) { - throw new InstrumentException("File is larger then max array size"); + throw new InternalException("File is larger then max array size"); } byte[] bytes = new byte[(int) len]; @@ -150,7 +150,7 @@ public byte[] readBytes() throws InstrumentException { throw new IOException(StringKit.format("File length is [{}] but read [{}]!", len, readLength)); } } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(in); } @@ -162,9 +162,9 @@ public byte[] readBytes() throws InstrumentException { * 读取文件内容 * * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public String readString() throws InstrumentException { + public String readString() throws InternalException { return new String(readBytes(), this.charset); } @@ -174,9 +174,9 @@ public String readString() throws InstrumentException { * @param 集合类型 * @param collection 集合 * @return 文件中的每行内容的集合 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public > T readLines(T collection) throws InstrumentException { + public > T readLines(T collection) throws InternalException { BufferedReader reader = null; try { reader = FileKit.getReader(file, charset); @@ -190,7 +190,7 @@ public > T readLines(T collection) throws Instrumen } return collection; } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(reader); } @@ -200,9 +200,9 @@ public > T readLines(T collection) throws Instrumen * 按照行处理文件内容 * * @param lineHandler 行处理器 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public void readLines(LineHandler lineHandler) throws InstrumentException { + public void readLines(LineHandler lineHandler) throws InternalException { BufferedReader reader = null; try { reader = FileKit.getReader(file, charset); @@ -216,9 +216,9 @@ public void readLines(LineHandler lineHandler) throws InstrumentException { * 从文件中读取每一行数据 * * @return 文件中的每行内容的集合 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public List readLines() throws InstrumentException { + public List readLines() throws InternalException { return readLines(new ArrayList<>()); } @@ -228,16 +228,16 @@ public List readLines() throws InstrumentException { * @param 读取的结果对象类型 * @param readerHandler Reader处理类 * @return 从文件中read出的数据 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public T read(ReaderHandler readerHandler) throws InstrumentException { + public T read(ReaderHandler readerHandler) throws InternalException { BufferedReader reader = null; T result; try { reader = FileKit.getReader(this.file, charset); result = readerHandler.handle(reader); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(reader); } @@ -248,9 +248,9 @@ public T read(ReaderHandler readerHandler) throws InstrumentException { * 获得一个文件读取器 * * @return BufferedReader对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public BufferedReader getReader() throws InstrumentException { + public BufferedReader getReader() throws InternalException { return IoKit.getReader(getInputStream(), this.charset); } @@ -258,13 +258,13 @@ public BufferedReader getReader() throws InstrumentException { * 获得输入流 * * @return 输入流 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public BufferedInputStream getInputStream() throws InstrumentException { + public BufferedInputStream getInputStream() throws InternalException { try { return new BufferedInputStream(new FileInputStream(this.file)); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -273,9 +273,9 @@ public BufferedInputStream getInputStream() throws InstrumentException { * * @param out 流 * @return 写出的流byte数 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public long writeToStream(OutputStream out) throws InstrumentException { + public long writeToStream(OutputStream out) throws InternalException { return writeToStream(out, false); } @@ -285,13 +285,13 @@ public long writeToStream(OutputStream out) throws InstrumentException { * @param out 流 * @param isClose 是否关闭输出流 * @return 写出的流byte数 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public long writeToStream(OutputStream out, boolean isClose) throws InstrumentException { + public long writeToStream(OutputStream out, boolean isClose) throws InternalException { try (FileInputStream in = new FileInputStream(this.file)) { return IoKit.copy(in, out); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { if (isClose) { IoKit.close(out); @@ -302,14 +302,14 @@ public long writeToStream(OutputStream out, boolean isClose) throws InstrumentEx /** * 检查文件 * - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - private void checkFile() throws InstrumentException { + private void checkFile() throws InternalException { if (false == file.exists()) { - throw new InstrumentException("File not exist : " + file); + throw new InternalException("File not exist : " + file); } if (false == file.isFile()) { - throw new InstrumentException("Not a file :" + file); + throw new InternalException("Not a file :" + file); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/file/FileWriter.java b/bus-core/src/main/java/org/aoju/bus/core/io/file/FileWriter.java index c4cd7dd20d..d1aa252aa5 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/io/file/FileWriter.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/file/FileWriter.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.file; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.toolkit.FileKit; @@ -132,16 +132,16 @@ public static FileWriter create(File file) { * @param content 写入的内容 * @param isAppend 是否追加 * @return 目标文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File write(String content, boolean isAppend) throws InstrumentException { + public File write(String content, boolean isAppend) throws InternalException { BufferedWriter writer = null; try { writer = getWriter(isAppend); writer.write(content); writer.flush(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(writer); } @@ -153,9 +153,9 @@ public File write(String content, boolean isAppend) throws InstrumentException { * * @param content 写入的内容 * @return 目标文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File write(String content) throws InstrumentException { + public File write(String content) throws InternalException { return write(content, false); } @@ -164,9 +164,9 @@ public File write(String content) throws InstrumentException { * * @param content 写入的内容 * @return 写入的文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File append(String content) throws InstrumentException { + public File append(String content) throws InternalException { return write(content, true); } @@ -176,9 +176,9 @@ public File append(String content) throws InstrumentException { * @param 集合元素类型 * @param list 列表 * @return 目标文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File writeLines(Iterable list) throws InstrumentException { + public File writeLines(Iterable list) throws InternalException { return writeLines(list, false); } @@ -188,9 +188,9 @@ public File writeLines(Iterable list) throws InstrumentException { * @param 集合元素类型 * @param list 列表 * @return 目标文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File appendLines(Iterable list) throws InstrumentException { + public File appendLines(Iterable list) throws InternalException { return writeLines(list, true); } @@ -201,9 +201,9 @@ public File appendLines(Iterable list) throws InstrumentException { * @param list 列表 * @param isAppend 是否追加 * @return 目标文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File writeLines(Iterable list, boolean isAppend) throws InstrumentException { + public File writeLines(Iterable list, boolean isAppend) throws InternalException { return writeLines(list, null, isAppend); } @@ -215,9 +215,9 @@ public File writeLines(Iterable list, boolean isAppend) throws Instrument * @param lineSeparator 换行符枚举(Windows、Mac或Linux换行符) * @param isAppend 是否追加 * @return 目标文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File writeLines(Iterable list, LineSeparator lineSeparator, boolean isAppend) throws InstrumentException { + public File writeLines(Iterable list, LineSeparator lineSeparator, boolean isAppend) throws InternalException { try (PrintWriter writer = getPrintWriter(isAppend)) { boolean isFirst = true; for (T t : list) { @@ -247,9 +247,9 @@ public File writeLines(Iterable list, LineSeparator lineSeparator, boolea * @param kvSeparator 键和值之间的分隔符,如果传入null使用默认分隔符" = " * @param isAppend 是否追加 * @return 目标文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File writeMap(Map map, String kvSeparator, boolean isAppend) throws InstrumentException { + public File writeMap(Map map, String kvSeparator, boolean isAppend) throws InternalException { return writeMap(map, null, kvSeparator, isAppend); } @@ -261,9 +261,9 @@ public File writeMap(Map map, String kvSeparator, boolean isAppend) throws * @param kvSeparator 键和值之间的分隔符,如果传入null使用默认分隔符" = " * @param isAppend 是否追加 * @return 目标文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File writeMap(Map map, LineSeparator lineSeparator, String kvSeparator, boolean isAppend) throws InstrumentException { + public File writeMap(Map map, LineSeparator lineSeparator, String kvSeparator, boolean isAppend) throws InternalException { if (null == kvSeparator) { kvSeparator = " = "; } @@ -286,9 +286,9 @@ public File writeMap(Map map, LineSeparator lineSeparator, String kvSepara * @param off 数据开始位置 * @param len 数据长度 * @return 目标文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File write(byte[] data, int off, int len) throws InstrumentException { + public File write(byte[] data, int off, int len) throws InternalException { return write(data, off, len, false); } @@ -299,9 +299,9 @@ public File write(byte[] data, int off, int len) throws InstrumentException { * @param off 数据开始位置 * @param len 数据长度 * @return 目标文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File append(byte[] data, int off, int len) throws InstrumentException { + public File append(byte[] data, int off, int len) throws InternalException { return write(data, off, len, true); } @@ -313,16 +313,16 @@ public File append(byte[] data, int off, int len) throws InstrumentException { * @param len 数据长度 * @param isAppend 是否追加模式 * @return 目标文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File write(byte[] data, int off, int len, boolean isAppend) throws InstrumentException { + public File write(byte[] data, int off, int len, boolean isAppend) throws InternalException { FileOutputStream out = null; try { out = new FileOutputStream(FileKit.touch(file), isAppend); out.write(data, off, len); out.flush(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(out); } @@ -335,9 +335,9 @@ public File write(byte[] data, int off, int len, boolean isAppend) throws Instru * * @param in 输入流,不关闭 * @return dest - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File writeFromStream(InputStream in) throws InstrumentException { + public File writeFromStream(InputStream in) throws InternalException { return writeFromStream(in, true); } @@ -347,15 +347,15 @@ public File writeFromStream(InputStream in) throws InstrumentException { * @param in 输入流,不关闭 * @param isClose 是否关闭输入流 * @return dest - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public File writeFromStream(InputStream in, boolean isClose) throws InstrumentException { + public File writeFromStream(InputStream in, boolean isClose) throws InternalException { FileOutputStream out = null; try { out = new FileOutputStream(FileKit.touch(file)); IoKit.copy(in, out); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(out); if (isClose) { @@ -369,13 +369,13 @@ public File writeFromStream(InputStream in, boolean isClose) throws InstrumentEx * 获得一个输出流对象 * * @return 输出流对象 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public BufferedOutputStream getOutputStream() throws InstrumentException { + public BufferedOutputStream getOutputStream() throws InternalException { try { return new BufferedOutputStream(new FileOutputStream(FileKit.touch(file))); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -384,13 +384,13 @@ public BufferedOutputStream getOutputStream() throws InstrumentException { * * @param isAppend 是否追加 * @return BufferedReader对象 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public BufferedWriter getWriter(boolean isAppend) throws InstrumentException { + public BufferedWriter getWriter(boolean isAppend) throws InternalException { try { return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(FileKit.touch(file), isAppend), charset)); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -399,21 +399,21 @@ public BufferedWriter getWriter(boolean isAppend) throws InstrumentException { * * @param isAppend 是否追加 * @return 打印对象 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public PrintWriter getPrintWriter(boolean isAppend) throws InstrumentException { + public PrintWriter getPrintWriter(boolean isAppend) throws InternalException { return new PrintWriter(getWriter(isAppend)); } /** * 检查文件 * - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - private void checkFile() throws InstrumentException { + private void checkFile() throws InternalException { Assert.notNull(file, "File to write content is null !"); if (this.file.exists() && false == file.isFile()) { - throw new InstrumentException("File [{}] is not a file !", this.file.getAbsoluteFile()); + throw new InternalException("File [{}] is not a file !", this.file.getAbsoluteFile()); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/file/LineReadWatcher.java b/bus-core/src/main/java/org/aoju/bus/core/io/file/LineReadWatcher.java index b2041c9a47..136f38576b 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/io/file/LineReadWatcher.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/file/LineReadWatcher.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.file; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.LineHandler; import org.aoju.bus.core.io.watcher.SimpleWatcher; import org.aoju.bus.core.toolkit.FileKit; @@ -90,7 +90,7 @@ public void onModify(WatchEvent event, Path currentPath) { // 记录当前读到的位置 randomAccessFile.seek(currentLength); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/file/Tailer.java b/bus-core/src/main/java/org/aoju/bus/core/io/file/Tailer.java index 95ebed1f33..066a8f4044 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/io/file/Tailer.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/file/Tailer.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.file; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.LineHandler; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.lang.Console; @@ -128,10 +128,10 @@ public Tailer(File file, java.nio.charset.Charset charset, LineHandler lineHandl */ private static void checkFile(File file) { if (false == file.exists()) { - throw new InstrumentException("File [{}] not exist !", file.getAbsolutePath()); + throw new InternalException("File [{}] not exist !", file.getAbsolutePath()); } if (false == file.isFile()) { - throw new InstrumentException("Path [{}] is not a file !", file.getAbsolutePath()); + throw new InternalException("Path [{}] is not a file !", file.getAbsolutePath()); } } @@ -152,7 +152,7 @@ public void start(boolean async) { try { this.readTail(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } final LineReadWatcher lineReadWatcher = new LineReadWatcher(this.randomAccessFile, this.charset, this.lineHandler); @@ -166,7 +166,7 @@ public void start(boolean async) { try { scheduledFuture.get(); } catch (ExecutionException | InterruptedException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } } @@ -231,7 +231,7 @@ private void readTail() throws IOException { try { this.randomAccessFile.seek(len); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/resource/BytesResource.java b/bus-core/src/main/java/org/aoju/bus/core/io/resource/BytesResource.java index e0f382dabb..884425d4da 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/io/resource/BytesResource.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/resource/BytesResource.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.resource; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.StringKit; import java.io.ByteArrayInputStream; @@ -81,12 +81,12 @@ public InputStream getStream() { } @Override - public String readString(Charset charset) throws InstrumentException { + public String readString(Charset charset) throws InternalException { return StringKit.toString(this.bytes, charset); } @Override - public byte[] readBytes() throws InstrumentException { + public byte[] readBytes() throws InternalException { return this.bytes; } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/resource/CharSequenceResource.java b/bus-core/src/main/java/org/aoju/bus/core/io/resource/CharSequenceResource.java index 1dc7778fbd..3bb481d579 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/io/resource/CharSequenceResource.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/resource/CharSequenceResource.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.resource; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.IoKit; import org.aoju.bus.core.toolkit.StringKit; @@ -101,12 +101,12 @@ public BufferedReader getReader(Charset charset) { } @Override - public String readString(Charset charset) throws InstrumentException { + public String readString(Charset charset) throws InternalException { return this.data.toString(); } @Override - public byte[] readBytes() throws InstrumentException { + public byte[] readBytes() throws InternalException { return this.data.toString().getBytes(this.charset); } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/resource/ClassPathResource.java b/bus-core/src/main/java/org/aoju/bus/core/io/resource/ClassPathResource.java index c8901228fa..c082d8dd7c 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/io/resource/ClassPathResource.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/resource/ClassPathResource.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.resource; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Symbol; import org.aoju.bus.core.toolkit.*; @@ -137,7 +137,7 @@ private void initUrl() { super.url = ClassLoader.getSystemResource(this.path); } if (null == super.url) { - throw new InstrumentException("Resource of path [{}] not exist!", this.path); + throw new InternalException("Resource of path [{}] not exist!", this.path); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/resource/FileObjectResource.java b/bus-core/src/main/java/org/aoju/bus/core/io/resource/FileObjectResource.java index 63401215c6..1ee734d22d 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/io/resource/FileObjectResource.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/resource/FileObjectResource.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.resource; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.IoKit; import javax.tools.FileObject; @@ -83,7 +83,7 @@ public InputStream getStream() { try { return this.fileObject.openInputStream(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -92,7 +92,7 @@ public BufferedReader getReader(Charset charset) { try { return IoKit.getReader(this.fileObject.openReader(false)); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/resource/MultiResource.java b/bus-core/src/main/java/org/aoju/bus/core/io/resource/MultiResource.java index bd9956f681..2ea5619db1 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/io/resource/MultiResource.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/resource/MultiResource.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.resource; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.CollKit; import java.io.BufferedReader; @@ -97,12 +97,12 @@ public BufferedReader getReader(Charset charset) { } @Override - public String readString(Charset charset) throws InstrumentException { + public String readString(Charset charset) throws InternalException { return resources.get(cursor).readString(charset); } @Override - public byte[] readBytes() throws InstrumentException { + public byte[] readBytes() throws InternalException { return resources.get(cursor).readBytes(); } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/resource/Resource.java b/bus-core/src/main/java/org/aoju/bus/core/io/resource/Resource.java index 250da37325..1f11d7b04e 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/io/resource/Resource.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/resource/Resource.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.resource; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.IoKit; import java.io.BufferedReader; @@ -91,9 +91,9 @@ default BufferedReader getReader(Charset charset) { * * @param charset 编码 * @return 读取资源内容 - * @throws InstrumentException 包装{@link IOException} + * @throws InternalException 包装{@link IOException} */ - default String readString(Charset charset) throws InstrumentException { + default String readString(Charset charset) throws InternalException { return IoKit.read(getReader(charset)); } @@ -102,9 +102,9 @@ default String readString(Charset charset) throws InstrumentException { * 关闭流并不影响下一次读取 * * @return 读取资源内容 - * @throws InstrumentException 包装IOException + * @throws InternalException 包装IOException */ - default byte[] readBytes() throws InstrumentException { + default byte[] readBytes() throws InternalException { return IoKit.readBytes(getStream()); } @@ -112,13 +112,13 @@ default byte[] readBytes() throws InstrumentException { * 将资源内容写出到流,不关闭输出流,但是关闭资源流 * * @param out 输出流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - default void writeTo(OutputStream out) throws InstrumentException { + default void writeTo(OutputStream out) throws InternalException { try (InputStream in = getStream()) { IoKit.copy(in, out); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/resource/UriResource.java b/bus-core/src/main/java/org/aoju/bus/core/io/resource/UriResource.java index 5dbf22254a..579af9ffde 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/io/resource/UriResource.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/resource/UriResource.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.resource; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Normal; import org.aoju.bus.core.toolkit.FileKit; import org.aoju.bus.core.toolkit.ObjectKit; @@ -100,7 +100,7 @@ public URL getUrl() { @Override public InputStream getStream() { if (null == this.url) { - throw new InstrumentException("Resource URL is null!"); + throw new InternalException("Resource URL is null!"); } return UriKit.getStream(url); } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/stream/BOMInputStream.java b/bus-core/src/main/java/org/aoju/bus/core/io/stream/BOMInputStream.java index 82aa7300db..752e601402 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/io/stream/BOMInputStream.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/stream/BOMInputStream.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.stream; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Charset; import java.io.IOException; @@ -99,7 +99,7 @@ public String getCharset() { try { init(); } catch (IOException ex) { - throw new InstrumentException(ex); + throw new InternalException(ex); } } return charset; diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/stream/FastByteOutputStream.java b/bus-core/src/main/java/org/aoju/bus/core/io/stream/FastByteOutputStream.java index 93d2f9ee80..1fadcb53ea 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/io/stream/FastByteOutputStream.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/stream/FastByteOutputStream.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.stream; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.buffer.FastByteBuffer; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.lang.Normal; @@ -89,9 +89,9 @@ public void reset() { * 写出 * * @param out 输出流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public void writeTo(OutputStream out) throws InstrumentException { + public void writeTo(OutputStream out) throws InternalException { final int index = buffer.index(); if (index < 0) { return; @@ -104,7 +104,7 @@ public void writeTo(OutputStream out) throws InstrumentException { } out.write(buffer.array(index), 0, buffer.offset()); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/stream/StreamBuffer.java b/bus-core/src/main/java/org/aoju/bus/core/io/stream/StreamBuffer.java index 17a5d0e803..f771710489 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/io/stream/StreamBuffer.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/stream/StreamBuffer.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.stream; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.lang.Normal; import org.aoju.bus.core.toolkit.IoKit; @@ -86,7 +86,7 @@ public String toString() { try { return toString(Charset.DEFAULT_CHARSET); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/stream/StringInputStream.java b/bus-core/src/main/java/org/aoju/bus/core/io/stream/StringInputStream.java index 92d876aa29..f88bd5f433 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/io/stream/StringInputStream.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/stream/StringInputStream.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.stream; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Charset; import java.io.ByteArrayInputStream; @@ -54,7 +54,7 @@ protected static byte[] toBytes(CharSequence text, java.nio.charset.Charset char try { return text.toString().getBytes(charset.name()); } catch (UnsupportedEncodingException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/watcher/WatchMonitor.java b/bus-core/src/main/java/org/aoju/bus/core/io/watcher/WatchMonitor.java index 73bd564046..0f3feefd29 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/io/watcher/WatchMonitor.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/watcher/WatchMonitor.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.watcher; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Symbol; import org.aoju.bus.core.toolkit.FileKit; import org.aoju.bus.core.toolkit.StringKit; @@ -280,7 +280,7 @@ public static WatchMonitor createAll(URL url, Watcher watcher) { try { return createAll(Paths.get(url.toURI()), watcher); } catch (URISyntaxException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -327,10 +327,10 @@ public static WatchMonitor createAll(Path path, Watcher watcher) { * 2、创建{@link WatchService} 对象 * * - * @throws InstrumentException 监听异常,IO异常时抛出此异常 + * @throws InternalException 监听异常,IO异常时抛出此异常 */ @Override - public void init() throws InstrumentException { + public void init() throws InternalException { //获取目录或文件路径 if (false == Files.exists(this.path, LinkOption.NOFOLLOW_LINKS)) { // 不存在的路径 @@ -348,7 +348,7 @@ public void init() throws InstrumentException { try { Files.createDirectories(this.path); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } else if (Files.isRegularFile(this.path, LinkOption.NOFOLLOW_LINKS)) { // 文件路径 @@ -387,11 +387,11 @@ public void watch() { * 开始监听事件,阻塞当前进程 * * @param watcher 监听 - * @throws InstrumentException 监听异常,如果监听关闭抛出此异常 + * @throws InternalException 监听异常,如果监听关闭抛出此异常 */ - public void watch(Watcher watcher) throws InstrumentException { + public void watch(Watcher watcher) throws InternalException { if (isClosed) { - throw new InstrumentException("Watch Monitor is closed !"); + throw new InternalException("Watch Monitor is closed !"); } // 按照层级注册路径及其子路径 diff --git a/bus-core/src/main/java/org/aoju/bus/core/io/watcher/WatchServer.java b/bus-core/src/main/java/org/aoju/bus/core/io/watcher/WatchServer.java index 43d7fa71ba..9c3de67e50 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/io/watcher/WatchServer.java +++ b/bus-core/src/main/java/org/aoju/bus/core/io/watcher/WatchServer.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.io.watcher; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Filter; import org.aoju.bus.core.toolkit.ArrayKit; import org.aoju.bus.core.toolkit.IoKit; @@ -76,14 +76,14 @@ public class WatchServer extends Thread implements Closeable, Serializable { * 2、创建{@link WatchService} 对象 * * - * @throws InstrumentException 监听异常,IO异常时抛出此异常 + * @throws InternalException 监听异常,IO异常时抛出此异常 */ - public void init() throws InstrumentException { + public void init() throws InternalException { //初始化监听 try { watchService = FileSystems.getDefault().newWatchService(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } isClosed = false; @@ -132,7 +132,7 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOEx } } catch (IOException e) { if (false == (e instanceof AccessDeniedException)) { - throw new InstrumentException(e); + throw new InternalException(e); } //对于禁止访问的目录,跳过监听 diff --git a/bus-core/src/main/java/org/aoju/bus/core/key/ID.java b/bus-core/src/main/java/org/aoju/bus/core/key/ID.java index 229f6efffb..adbbf19312 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/key/ID.java +++ b/bus-core/src/main/java/org/aoju/bus/core/key/ID.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.key; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.instance.Instances; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.toolkit.NetKit; @@ -181,7 +181,7 @@ public static long getDataCenterId(long maxDatacenterId) { byte[] mac = null; try { mac = NetKit.getLocalHardwareAddress(); - } catch (InstrumentException ignore) { + } catch (InternalException ignore) { // ignore } if (null != mac) { @@ -210,7 +210,7 @@ public static long getWorkerId(long datacenterId, long maxWorkerId) { mpid.append(datacenterId); try { mpid.append(RuntimeKit.getPid()); - } catch (InstrumentException igonre) { + } catch (InternalException igonre) { // ignore } // MAC + PID 的 hashcode 获取16个低位 diff --git a/bus-core/src/main/java/org/aoju/bus/core/lang/FileType.java b/bus-core/src/main/java/org/aoju/bus/core/lang/FileType.java index 6cd1a01b5c..7b8e8a9b3e 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/lang/FileType.java +++ b/bus-core/src/main/java/org/aoju/bus/core/lang/FileType.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.lang; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.FileKit; import org.aoju.bus.core.toolkit.IoKit; import org.aoju.bus.core.toolkit.StringKit; @@ -75,49 +75,59 @@ public class FileType { public static final String TYPE_PPS = ".pps"; public static final String TYPE_PPSX = ".ppsx"; /** - * Photoshop的专用格式Photoshop + * psd格式,Photoshop的专用格式Photoshop */ public static final String TYPE_PSD = "psd"; /** - * 图形交换格式 + * gif格式 */ public static final String TYPE_GIF = "gif"; /** - * 联合照片 + * jpg格式 */ public static final String TYPE_JPG = "jpg"; /** - * 联合照片 + * jpeg格式 */ public static final String TYPE_JPEG = "jpeg"; /** - * 英文Bitmap(位图)的简写,它是Windows操作系统中的标准图像文件格式 + * bmp格式 */ public static final String TYPE_BMP = "bmp"; /** - * 可移植网络图形 + * png格式 */ public static final String TYPE_PNG = "png"; /** - * 纯文本文件 + * csv格式 */ public static final String TYPE_CSV = "csv"; /** - * PDF文件 + * pdf格式 */ public static final String TYPE_PDF = "pdf"; /** - * 影像文件 + * dcm格式 */ public static final String TYPE_DCM = "dcm"; /** - * 图片 + * svg格式 */ - public static final Map PICS = new HashMap() { + public static final String TYPE_SVG = "svg"; + + /** + * txt格式 + */ + public static final String TYPE_TXT = "txt"; + + /** + * 图片格式 + */ + public static final Map PICS = new HashMap<>() { { put(".jpe", "image/jpeg"); put(".jpeg", "image/jpeg"); @@ -161,7 +171,7 @@ public class FileType { /** * 文档 */ - public static final Map DOCS = new HashMap() { + public static final Map DOCS = new HashMap<>() { { // txt put(".txt", "text/plain"); @@ -388,7 +398,7 @@ public class FileType { /** * 压缩文档 */ - public static final Map ZIPDOCS = new HashMap() { + public static final Map ZIPDOCS = new HashMap<>() { { put(".7z", "application/x-7z-compressed"); put(".z", "application/x-compress"); @@ -404,7 +414,7 @@ public class FileType { /** * 视频 */ - public static final Map VIDEOS = new HashMap() { + public static final Map VIDEOS = new HashMap<>() { { put(".flv", "video/x-flv"); put(".3gp", "video/3gpp"); @@ -455,7 +465,7 @@ public class FileType { /** * 音频 */ - public static final Map AUDIOS = new HashMap() { + public static final Map AUDIOS = new HashMap<>() { { put(".mp3", "audio/mpeg"); put(".wma", "audio/x-ms-wma"); @@ -499,7 +509,7 @@ public class FileType { /** * 其他 */ - public static final Map OTHER = new HashMap() { + public static final Map OTHER = new HashMap<>() { { // xml类型文件 put(".asa", "application/xml"); @@ -747,7 +757,7 @@ public class FileType { /** * 文件信息头 */ - public static final Map IHDR = new HashMap() { + public static final Map IHDR = new HashMap<>() { { // JPEG (jpg) put("ffd8ffe", "jpg"); @@ -896,9 +906,9 @@ public static String getType(String fileStreamHexHead) { * * @param in {@link InputStream} * @return 类型, 文件的扩展名, 未找到为null - * @throws InstrumentException 读取流引起的异常 + * @throws InternalException 读取流引起的异常 */ - public static String getType(InputStream in) throws InstrumentException { + public static String getType(InputStream in) throws InternalException { return getType(IoKit.readHex28Upper(in)); } @@ -907,9 +917,9 @@ public static String getType(InputStream in) throws InstrumentException { * * @param file 文件 {@link File} * @return 类型, 文件的扩展名, 未找到为null - * @throws InstrumentException 读取文件引起的异常 + * @throws InternalException 读取文件引起的异常 */ - public static String getType(File file) throws InstrumentException { + public static String getType(File file) throws InternalException { FileInputStream in = null; try { in = IoKit.toStream(file); @@ -961,6 +971,8 @@ public static String getType(InputStream in, String filename) { typeName = "war"; } else if ("ofd".equalsIgnoreCase(extName)) { typeName = "ofd"; + } else if ("apk".equalsIgnoreCase(extName)) { + typeName = "apk"; } } else if ("jar".equals(typeName)) { // wps编辑过的.xlsx文件与.jar的开头相同,通过扩展名判断 @@ -971,6 +983,10 @@ public static String getType(InputStream in, String filename) { typeName = "docx"; } else if ("pptx".equalsIgnoreCase(extName)) { typeName = "pptx"; + } else if ("zip".equalsIgnoreCase(extName)) { + typeName = "zip"; + } else if ("apk".equalsIgnoreCase(extName)) { + typeName = "apk"; } } return typeName; @@ -981,9 +997,9 @@ public static String getType(InputStream in, String filename) { * * @param path 路径,绝对路径或相对ClassPath的路径 * @return 类型 - * @throws InstrumentException 读取文件引起的异常 + * @throws InternalException 读取文件引起的异常 */ - public static String getTypeByPath(String path) throws InstrumentException { + public static String getTypeByPath(String path) throws InternalException { return getType(FileKit.file(path)); } diff --git a/bus-core/src/main/java/org/aoju/bus/core/lang/Fonts.java b/bus-core/src/main/java/org/aoju/bus/core/lang/Fonts.java index 9be76f68d2..0558dfc16e 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/lang/Fonts.java +++ b/bus-core/src/main/java/org/aoju/bus/core/lang/Fonts.java @@ -1,6 +1,6 @@ package org.aoju.bus.core.lang; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import java.awt.*; import java.io.File; @@ -60,7 +60,7 @@ public static Font createFont(File fontFile) { try { return Font.createFont(Font.TYPE1_FONT, fontFile); } catch (Exception e1) { - throw new InstrumentException(e); + throw new InternalException(e); } } } @@ -80,10 +80,10 @@ public static Font createFont(InputStream fontStream) { try { return Font.createFont(Font.TYPE1_FONT, fontStream); } catch (Exception e1) { - throw new InstrumentException(e1); + throw new InternalException(e1); } } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/lang/Pid.java b/bus-core/src/main/java/org/aoju/bus/core/lang/Pid.java index 56bd97935e..58fcf8e677 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/lang/Pid.java +++ b/bus-core/src/main/java/org/aoju/bus/core/lang/Pid.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.lang; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.StringKit; import java.lang.management.ManagementFactory; @@ -51,12 +51,12 @@ public enum Pid { * 获取当前进程ID,首先获取进程名称,读取@前的ID值,如果不存在,则读取进程名的hash值 * * @return 进程ID - * @throws InstrumentException 进程名称为空 + * @throws InternalException 进程名称为空 */ - private static int getPid() throws InstrumentException { + private static int getPid() throws InternalException { final String processName = ManagementFactory.getRuntimeMXBean().getName(); if (StringKit.isBlank(processName)) { - throw new InstrumentException("Process name is blank!"); + throw new InternalException("Process name is blank!"); } final int atIndex = processName.indexOf('@'); if (atIndex > 0) { diff --git a/bus-core/src/main/java/org/aoju/bus/core/lang/caller/StackTraceCaller.java b/bus-core/src/main/java/org/aoju/bus/core/lang/caller/StackTraceCaller.java index 2368842eb1..453d7e54c9 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/lang/caller/StackTraceCaller.java +++ b/bus-core/src/main/java/org/aoju/bus/core/lang/caller/StackTraceCaller.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.lang.caller; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; /** * 通过StackTrace方式获取调用者 此方式效率最低,不推荐使用 @@ -47,7 +47,7 @@ public Class getCaller() { try { return Class.forName(className); } catch (ClassNotFoundException e) { - throw new InstrumentException("[{}] not found!", className); + throw new InternalException("[{}] not found!", className); } } @@ -61,7 +61,7 @@ public Class getCallers() { try { return Class.forName(className); } catch (ClassNotFoundException e) { - throw new InstrumentException("[{}] not found!", className); + throw new InternalException("[{}] not found!", className); } } @@ -75,7 +75,7 @@ public Class getCaller(int depth) { try { return Class.forName(className); } catch (ClassNotFoundException e) { - throw new InstrumentException("[{}] not found!", className); + throw new InternalException("[{}] not found!", className); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/lang/reflect/LookupFactory.java b/bus-core/src/main/java/org/aoju/bus/core/lang/reflect/LookupFactory.java index 090581a1e5..5ba0ca756c 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/lang/reflect/LookupFactory.java +++ b/bus-core/src/main/java/org/aoju/bus/core/lang/reflect/LookupFactory.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.lang.reflect; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import java.lang.invoke.MethodHandles; import java.lang.reflect.Constructor; @@ -84,7 +84,7 @@ public static MethodHandles.Lookup lookup(Class callerClass) { try { return (MethodHandles.Lookup) privateLookupInMethod.invoke(MethodHandles.class, callerClass, MethodHandles.lookup()); } catch (IllegalAccessException | InvocationTargetException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } // jdk 8 diff --git a/bus-core/src/main/java/org/aoju/bus/core/lang/reflect/MethodHandle.java b/bus-core/src/main/java/org/aoju/bus/core/lang/reflect/MethodHandle.java index 077bba52df..14ca611dd0 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/lang/reflect/MethodHandle.java +++ b/bus-core/src/main/java/org/aoju/bus/core/lang/reflect/MethodHandle.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.lang.reflect; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.toolkit.ReflectKit; import org.aoju.bus.core.toolkit.StringKit; @@ -96,7 +96,7 @@ public static java.lang.invoke.MethodHandle findMethod(Class callerClass, Str } catch (NoSuchMethodException ignore) { //ignore } catch (IllegalAccessException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -128,7 +128,7 @@ public static java.lang.invoke.MethodHandle findConstructor(Class callerClass } catch (NoSuchMethodException e) { return null; } catch (IllegalAccessException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -160,7 +160,7 @@ public static T invokeSpecial(Object object, String methodName, Object... ar final Method method = ReflectKit.getMethodOfObject(object, methodName, args); if (null == method) { - throw new InstrumentException("No such method: [{}] from [{}]", methodName, object.getClass()); + throw new InternalException("No such method: [{}] from [{}]", methodName, object.getClass()); } return invokeSpecial(object, method, args); } @@ -239,7 +239,7 @@ public static T invoke(boolean isSpecial, Object object, Method method, Obje } return (T) handle.invokeWithArguments(args); } catch (Throwable e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/lang/tree/TreeBuilder.java b/bus-core/src/main/java/org/aoju/bus/core/lang/tree/TreeBuilder.java index 9c57312d16..2df953c9cf 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/lang/tree/TreeBuilder.java +++ b/bus-core/src/main/java/org/aoju/bus/core/lang/tree/TreeBuilder.java @@ -181,6 +181,18 @@ public TreeBuilder append(Iterable> trees) { * @return this */ public TreeBuilder append(List list, NodeParser nodeParser) { + return append(list, null, nodeParser); + } + + /** + * 增加节点列表,增加的节点是不带子节点的 + * + * @param list Bean列表 + * @param Bean类型 + * @param nodeParser 节点转换器,用于定义一个Bean如何转换为Tree节点 + * @return this + */ + public TreeBuilder append(List list, E rootId, NodeParser nodeParser) { checkBuilt(); final NodeConfig config = this.root.getConfig(); @@ -189,6 +201,9 @@ public TreeBuilder append(List list, NodeParser nodeParser) { for (T t : list) { node = new Tree<>(config); nodeParser.parse(t, node); + if (null != rootId && false == rootId.getClass().equals(node.getId().getClass())) { + throw new IllegalArgumentException("rootId type is node.getId().getClass()!"); + } map.put(node.getId(), node); } return append(map); diff --git a/bus-core/src/main/java/org/aoju/bus/core/loader/JarLoaders.java b/bus-core/src/main/java/org/aoju/bus/core/loader/JarLoaders.java index 2a0b271c9b..2eef054598 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/loader/JarLoaders.java +++ b/bus-core/src/main/java/org/aoju/bus/core/loader/JarLoaders.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.loader; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.*; import java.io.File; @@ -104,9 +104,9 @@ public static JarLoaders loadJar(File jarFile) { * * @param loader {@link URLClassLoader} * @param jarFile 被加载的jar - * @throws InstrumentException IO异常包装和执行异常 + * @throws InternalException IO异常包装和执行异常 */ - public static void loadJar(URLClassLoader loader, File jarFile) throws InstrumentException { + public static void loadJar(URLClassLoader loader, File jarFile) throws InternalException { try { final Method method = ClassKit.getDeclaredMethod(URLClassLoader.class, "addURL", URL.class); if (null != method) { @@ -117,7 +117,7 @@ public static void loadJar(URLClassLoader loader, File jarFile) throws Instrumen } } } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -172,7 +172,7 @@ public JarLoaders addJar(File jarFile) { super.addURL(jar.toURI().toURL()); } } catch (MalformedURLException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return this; } diff --git a/bus-core/src/main/java/org/aoju/bus/core/scanner/ClassScaner.java b/bus-core/src/main/java/org/aoju/bus/core/scanner/ClassScaner.java index 5e2fca2bda..0db75e2e67 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/scanner/ClassScaner.java +++ b/bus-core/src/main/java/org/aoju/bus/core/scanner/ClassScaner.java @@ -26,7 +26,7 @@ package org.aoju.bus.core.scanner; import org.aoju.bus.core.collection.EnumerationIterator; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.lang.FileType; import org.aoju.bus.core.lang.Normal; @@ -294,7 +294,7 @@ private void scanFile(File file, String rootDir) { try { scanJar(new JarFile(file)); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } } else if (file.isDirectory()) { diff --git a/bus-core/src/main/java/org/aoju/bus/core/text/Lookups.java b/bus-core/src/main/java/org/aoju/bus/core/text/Lookups.java index fa9b937808..6db602ab70 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/text/Lookups.java +++ b/bus-core/src/main/java/org/aoju/bus/core/text/Lookups.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.text; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import java.util.Map; @@ -129,7 +129,7 @@ public String lookup(String key) { try { return System.getProperty(key); } catch (SecurityException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } return null; diff --git a/bus-core/src/main/java/org/aoju/bus/core/text/TextJoiner.java b/bus-core/src/main/java/org/aoju/bus/core/text/TextJoiner.java index b52d3abde0..f5cb04fa7f 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/text/TextJoiner.java +++ b/bus-core/src/main/java/org/aoju/bus/core/text/TextJoiner.java @@ -1,7 +1,7 @@ package org.aoju.bus.core.text; import org.aoju.bus.core.collection.ArrayIterator; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Normal; import org.aoju.bus.core.toolkit.ArrayKit; import org.aoju.bus.core.toolkit.IterKit; @@ -329,7 +329,7 @@ public TextJoiner append(CharSequence text, int startInclude, int endExclude) { appendable.append(suffix); } } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return this; } diff --git a/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvParser.java b/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvParser.java index 862abcffbc..a9106104b7 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvParser.java +++ b/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvParser.java @@ -26,7 +26,7 @@ package org.aoju.bus.core.text.csv; import org.aoju.bus.core.collection.ComputeIterator; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Normal; import org.aoju.bus.core.lang.Symbol; import org.aoju.bus.core.text.TextBuilder; @@ -128,9 +128,9 @@ public List getHeader() { * 读取下一行数据 * * @return CsvRow - * @throws InstrumentException IO读取异常 + * @throws InternalException IO读取异常 */ - public CsvRow nextRow() throws InstrumentException { + public CsvRow nextRow() throws InternalException { long startingLineNo; List currentFields; int fieldCount; @@ -152,7 +152,7 @@ public CsvRow nextRow() throws InstrumentException { if (firstLineFieldCount == -1) { firstLineFieldCount = fieldCount; } else if (fieldCount != firstLineFieldCount) { - throw new InstrumentException(String.format("Line %d has %d fields, but first line has %d fields", lineNo, fieldCount, firstLineFieldCount)); + throw new InternalException(String.format("Line %d has %d fields, but first line has %d fields", lineNo, fieldCount, firstLineFieldCount)); } } @@ -201,9 +201,9 @@ private void initHeader(final List currentFields) { * 行号要考虑注释行和引号包装的内容中的换行 * * @return 一行数据 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - private List readLine() throws InstrumentException { + private List readLine() throws InternalException { // 矫正行号 // 当一行内容包含多行数据时,记录首行行号,但是读取下一行时,需要把多行内容的行数加上 if (inQuotesLineCount > 0) { @@ -406,7 +406,7 @@ int read(Reader reader) { try { length = reader.read(this.buf); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } this.mark = 0; this.position = 0; diff --git a/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvReader.java b/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvReader.java index 63fdd0740e..5ab0422d62 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvReader.java +++ b/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvReader.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.text.csv; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.toolkit.FileKit; @@ -169,9 +169,9 @@ public void setErrorOnDifferentFieldCount(boolean errorOnDifferentFieldCount) { * * @param file CSV文件 * @return {@link CsvData},包含数据列表和行信息 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public CsvData read(File file) throws InstrumentException { + public CsvData read(File file) throws InternalException { return read(file, Charset.UTF_8); } @@ -201,9 +201,9 @@ public void read(String csvStr, CsvHandler rowHandler) { * @param file CSV文件 * @param charset 文件编码,默认系统编码 * @return {@link CsvData},包含数据列表和行信息 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public CsvData read(File file, java.nio.charset.Charset charset) throws InstrumentException { + public CsvData read(File file, java.nio.charset.Charset charset) throws InternalException { return read(Objects.requireNonNull(file.toPath(), "file must not be null"), charset); } @@ -212,9 +212,9 @@ public CsvData read(File file, java.nio.charset.Charset charset) throws Instrume * * @param path CSV文件 * @return {@link CsvData},包含数据列表和行信息 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public CsvData read(Path path) throws InstrumentException { + public CsvData read(Path path) throws InternalException { return read(path, Charset.UTF_8); } @@ -224,14 +224,14 @@ public CsvData read(Path path) throws InstrumentException { * @param path CSV文件 * @param charset 文件编码,默认系统编码 * @return {@link CsvData},包含数据列表和行信息 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public CsvData read(Path path, java.nio.charset.Charset charset) throws InstrumentException { + public CsvData read(Path path, java.nio.charset.Charset charset) throws InternalException { Assert.notNull(path, "path must not be null"); try (Reader reader = FileKit.getReader(path, charset)) { return read(reader); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -240,9 +240,9 @@ public CsvData read(Path path, java.nio.charset.Charset charset) throws Instrume * * @param reader Reader * @return {@link CsvData},包含数据列表和行信息 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public CsvData read(Reader reader) throws InstrumentException { + public CsvData read(Reader reader) throws InternalException { final CsvParser csvParser = parse(reader); final List rows = new ArrayList<>(); read(csvParser, rows::add); @@ -301,9 +301,9 @@ public List read(String csvStr, Class clazz) { * * @param reader Reader * @return {@link CsvData},包含数据列表和行信息 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public List> readMapList(Reader reader) throws InstrumentException { + public List> readMapList(Reader reader) throws InternalException { // 此方法必须包含标题 this.config.setContainsHeader(true); @@ -335,9 +335,9 @@ public List read(Reader reader, Class clazz) { * * @param reader Reader * @return CsvParser - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - private CsvParser parse(Reader reader) throws InstrumentException { + private CsvParser parse(Reader reader) throws InternalException { return new CsvParser(reader, config); } @@ -378,7 +378,7 @@ public Stream stream() { try { close(); } catch (final IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } }); } diff --git a/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvWriter.java b/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvWriter.java index 469bca5c06..8dede9e205 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvWriter.java +++ b/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvWriter.java @@ -27,7 +27,7 @@ import org.aoju.bus.core.collection.ArrayIterator; import org.aoju.bus.core.convert.Convert; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.lang.Symbol; @@ -190,9 +190,9 @@ public void setLineDelimiter(char[] lineDelimiter) { * * @param lines 多行数据 * @return this - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public CsvWriter write(String[]... lines) throws InstrumentException { + public CsvWriter write(String[]... lines) throws InternalException { return write(new ArrayIterator<>(lines)); } @@ -260,9 +260,9 @@ public CsvWriter writeBeans(Collection beans) { * * @param fields 字段列表 ({@code null} 值会被做为空值追加) * @return this - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public CsvWriter writeLine(String... fields) throws InstrumentException { + public CsvWriter writeLine(String... fields) throws InternalException { if (ArrayKit.isEmpty(fields)) { return writeLine(); } @@ -274,13 +274,13 @@ public CsvWriter writeLine(String... fields) throws InstrumentException { * 追加新行(换行) * * @return this - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public CsvWriter writeLine() throws InstrumentException { + public CsvWriter writeLine() throws InternalException { try { writer.write(config.lineDelimiter); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } newline = true; return this; @@ -306,7 +306,7 @@ public CsvWriter writeComment(String comment) { writer.write(comment); newline = true; } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return this; } @@ -317,11 +317,11 @@ public void close() { } @Override - public void flush() throws InstrumentException { + public void flush() throws InternalException { try { writer.flush(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -330,9 +330,9 @@ public void flush() throws InstrumentException { * * @param fields 字段列表 ({@code null} 值会被做为空值追加 * @return this - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public CsvWriter writeHeaderLine(String... fields) throws InstrumentException { + public CsvWriter writeHeaderLine(String... fields) throws InternalException { final Map headerAlias = this.config.headerAlias; if (MapKit.isNotEmpty(headerAlias)) { // 标题别名替换 @@ -351,13 +351,13 @@ public CsvWriter writeHeaderLine(String... fields) throws InstrumentException { * 追加一行,末尾会自动换行,但是追加前不会换行 * * @param fields 字段列表 ({@code null} 值会被做为空值追加) - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - private void appendLine(final String... fields) throws InstrumentException { + private void appendLine(final String... fields) throws InternalException { try { doAppendLine(fields); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/thread/GlobalThread.java b/bus-core/src/main/java/org/aoju/bus/core/thread/GlobalThread.java index d63819280a..d248b9dc26 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/thread/GlobalThread.java +++ b/bus-core/src/main/java/org/aoju/bus/core/thread/GlobalThread.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.thread; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; @@ -91,7 +91,7 @@ public static void execute(Runnable runnable) { try { executor.execute(runnable); } catch (Exception e) { - throw new InstrumentException("Exception when running task!"); + throw new InternalException("Exception when running task!"); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/thread/SyncFinisher.java b/bus-core/src/main/java/org/aoju/bus/core/thread/SyncFinisher.java index 3c39c016d8..34c4528244 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/thread/SyncFinisher.java +++ b/bus-core/src/main/java/org/aoju/bus/core/thread/SyncFinisher.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.thread; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.ThreadKit; import java.util.LinkedHashSet; @@ -151,7 +151,7 @@ public void start(boolean sync) { try { this.endLatch.await(); } catch (InterruptedException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } } @@ -202,7 +202,7 @@ public void run() { try { beginLatch.await(); } catch (InterruptedException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } try { diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/ArrayKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/ArrayKit.java index c294152372..f35c883067 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/ArrayKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/ArrayKit.java @@ -29,7 +29,7 @@ import org.aoju.bus.core.builder.ToStringBuilder; import org.aoju.bus.core.builder.ToStringStyle; import org.aoju.bus.core.collection.UniqueKeySet; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Optional; import org.aoju.bus.core.lang.*; import org.aoju.bus.core.lang.mutable.MutableInt; @@ -7612,7 +7612,7 @@ public static boolean[] unWrap(Boolean... values) { * * @param object 对象,可以是对象数组或者基本类型数组 * @return 包装类型数组或对象数组 - * @throws InstrumentException 对象为非数组 + * @throws InternalException 对象为非数组 */ public static Object[] wrap(Object object) { if (null == object) { @@ -7641,11 +7641,11 @@ public static Object[] wrap(Object object) { case "double": return wrap((double[]) object); default: - throw new InstrumentException(e); + throw new InternalException(e); } } } - throw new InstrumentException("is not Array!"); + throw new InternalException("is not Array!"); } /** diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/BeanKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/BeanKit.java index 246bbf0c68..3e9a3d2241 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/BeanKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/BeanKit.java @@ -30,7 +30,7 @@ import org.aoju.bus.core.beans.copier.CopyOptions; import org.aoju.bus.core.beans.copier.ValueProvider; import org.aoju.bus.core.convert.Convert; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Editor; import org.aoju.bus.core.lang.Filter; import org.aoju.bus.core.lang.Normal; @@ -330,14 +330,14 @@ public static void descForEach(Class clazz, Consumer ac * * @param clazz Bean类 * @return 字段描述数组 - * @throws InstrumentException 获取属性异常 + * @throws InternalException 获取属性异常 */ - public static PropertyDescriptor[] getPropertyDescriptors(Class clazz) throws InstrumentException { + public static PropertyDescriptor[] getPropertyDescriptors(Class clazz) throws InternalException { BeanInfo beanInfo; try { beanInfo = Introspector.getBeanInfo(clazz); } catch (IntrospectionException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return ArrayKit.filter(beanInfo.getPropertyDescriptors(), (Filter) t -> { // 过滤掉getClass方法 @@ -953,7 +953,7 @@ public static void trimAllFields(Object bean) { } } } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -980,7 +980,7 @@ public static void replaceStrFields(Object bean) { } } } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/BufferKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/BufferKit.java index 317ebe55a9..f6f845718b 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/BufferKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/BufferKit.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.toolkit; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Normal; import org.aoju.bus.core.lang.Symbol; @@ -234,7 +234,7 @@ public static String readLine(ByteBuffer buffer) { buffer.reset(); return text; } catch (CharacterCodingException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/CharsKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/CharsKit.java index fa12ddbe41..32a1306238 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/CharsKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/CharsKit.java @@ -1422,6 +1422,28 @@ public static String format(CharSequence template, Map map, boolean ignore return TextFormatter.format(template, map, ignoreNull); } + /** + * 指定字符串数组中,是否包含空字符串 + * 如果传入参数对象不是为空,则返回false + * 如果传入的参数不是String则返回false 如果字符串包含字母,不区分大小写,则返回true + * + * @param obj 对象 + * @return 如果为字符串, 是否有字母 + */ + public static boolean hasLetter(Object obj) { + if (null == obj) { + return false; + } else if (obj instanceof String) { + char[] chars = ((String) obj).toCharArray(); + for (char c : chars) { + if (isLetter(c)) { + return true; + } + } + } + return false; + } + /** * 改进JDK subString * index从0开始计算,最后一个字符为-1 @@ -2888,6 +2910,70 @@ public static String replace(CharSequence text, int startInclude, int endExclude return stringBuilder.toString(); } + /** + * 替换字符串中最后一个指定字符串 + * + * @param text 字符串 + * @param searchStr 被查找的字符串 + * @param replacedChar 被替换的字符串 + * @return 替换后的字符串 + */ + public static String replaceLast(CharSequence text, CharSequence searchStr, CharSequence replacedChar) { + return replaceLast(text, searchStr, replacedChar, false); + } + + /** + * 替换字符串中最后一个指定字符串 + * + * @param text 字符串 + * @param searchStr 被查找的字符串 + * @param replacedChar 被替换的字符串 + * @param ignoreCase 是否忽略大小写 + * @return 替换后的字符串 + */ + public static String replaceLast(CharSequence text, CharSequence searchStr, CharSequence replacedChar, boolean ignoreCase) { + if (isEmpty(text)) { + return toString(text); + } + int lastIndex = lastIndexOf(text, searchStr, text.length(), ignoreCase); + if (-1 == lastIndex) { + return toString(text); + } + return replace(text, lastIndex, searchStr, replacedChar, ignoreCase); + } + + /** + * 替换字符串中第一个指定字符串 + * + * @param str 字符串 + * @param searchStr 被查找的字符串 + * @param replacedStr 被替换的字符串 + * @return 替换后的字符串 + */ + public static String replaceFirst(CharSequence str, CharSequence searchStr, CharSequence replacedStr) { + return replaceFirst(str, searchStr, replacedStr, false); + } + + /** + * 替换字符串中第一个指定字符串 + * + * @param str 字符串 + * @param searchStr 被查找的字符串 + * @param replacedStr 被替换的字符串 + * @param ignoreCase 是否忽略大小写 + * @return 替换后的字符串 + */ + public static String replaceFirst(CharSequence str, CharSequence searchStr, CharSequence replacedStr, boolean ignoreCase) { + if (isEmpty(str)) { + return toString(str); + } + int startInclude = indexOf(str, searchStr, 0, ignoreCase); + if (-1 == startInclude) { + return toString(str); + } + return replace(str, startInclude, startInclude + searchStr.length(), replacedStr); + } + /** * 替换指定字符串的指定区间内字符为"*" * diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/ClassKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/ClassKit.java index b95af0a3f2..3c896c2ee2 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/ClassKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/ClassKit.java @@ -31,7 +31,7 @@ import org.aoju.bus.core.beans.copier.ValueProvider; import org.aoju.bus.core.compiler.JavaSourceCompiler; import org.aoju.bus.core.convert.BasicType; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.instance.Instances; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Filter; @@ -426,7 +426,7 @@ public static T invoke(String classNameWithMethodName, Object[] args) { */ public static T invoke(String classNameWithMethodName, boolean isSingleton, Object... args) { if (StringKit.isBlank(classNameWithMethodName)) { - throw new InstrumentException("Blank classNameDotMethodName!"); + throw new InternalException("Blank classNameDotMethodName!"); } int splitIndex = classNameWithMethodName.lastIndexOf(Symbol.C_SHAPE); @@ -434,7 +434,7 @@ public static T invoke(String classNameWithMethodName, boolean isSingleton, splitIndex = classNameWithMethodName.lastIndexOf(Symbol.C_DOT); } if (splitIndex <= 0) { - throw new InstrumentException("Invalid classNameWithMethodName [{}]!", classNameWithMethodName); + throw new InternalException("Invalid classNameWithMethodName [{}]!", classNameWithMethodName); } final String className = classNameWithMethodName.substring(0, splitIndex); @@ -484,7 +484,7 @@ public static T invoke(String className, String methodName, boolean isSingle return ReflectKit.invoke(isSingleton ? Instances.singletion(clazz) : clazz.newInstance(), method, args); } } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1031,10 +1031,10 @@ public static URL getClassPathURL() { * * @param resource 资源(相对Classpath的路径) * @return 资源URL - * @throws InstrumentException 异常 + * @throws InternalException 异常 * @see FileKit#getResource(String) */ - public static URL getResourceURL(String resource) throws InstrumentException { + public static URL getResourceURL(String resource) throws InternalException { return FileKit.getResource(resource); } @@ -1067,9 +1067,9 @@ public static T fillBean(T bean, ValueProvider valueProvider, CopyOp * @param 对象 * @param name 类名 * @return 类名对应的类 - * @throws InstrumentException 没有类名对应的类时抛出此异常 + * @throws InternalException 没有类名对应的类时抛出此异常 */ - public static Class loadClass(String name) throws InstrumentException { + public static Class loadClass(String name) throws InternalException { return loadClass(name, true); } @@ -1087,9 +1087,9 @@ public static Class loadClass(String name) throws InstrumentException { * @param name 类名 * @param isInitialized 是否初始化类(调用static模块内容和初始化static属性) * @return 类名对应的类 - * @throws InstrumentException 没有类名对应的类时抛出此异常 + * @throws InternalException 没有类名对应的类时抛出此异常 */ - public static Class loadClass(String name, boolean isInitialized) throws InstrumentException { + public static Class loadClass(String name, boolean isInitialized) throws InternalException { return (Class) loadClass(name, null, isInitialized); } @@ -1109,9 +1109,9 @@ public static Class loadClass(String name, boolean isInitialized) throws * @param classLoader {@link ClassLoader},{@code null} 则使用系统默认ClassLoader * @param isInitialized 是否初始化类(调用static模块内容和初始化static属性) * @return 类名对应的类 - * @throws InstrumentException 没有类名对应的类时抛出此异常 + * @throws InternalException 没有类名对应的类时抛出此异常 */ - public static Class loadClass(String name, ClassLoader classLoader, boolean isInitialized) throws InstrumentException { + public static Class loadClass(String name, ClassLoader classLoader, boolean isInitialized) throws InternalException { Assert.notNull(name, "Name must not be null"); // 自动将包名中的"/"替换为"." @@ -1168,7 +1168,7 @@ public static Class loadClass(File jarOrDir, String name) { try { return getJarClassLoader(jarOrDir).loadClass(name); } catch (ClassNotFoundException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -3482,7 +3482,7 @@ public static Manifest getManifest(Class cls) { try { connection = url.openConnection(); } catch (final IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (connection instanceof JarURLConnection) { @@ -3497,16 +3497,16 @@ public static Manifest getManifest(Class cls) { * * @param classpathItem 文件路径 * @return Manifest - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static Manifest getManifest(File classpathItem) throws InstrumentException { + public static Manifest getManifest(File classpathItem) throws InternalException { Manifest manifest = null; if (classpathItem.isFile()) { try (JarFile jarFile = new JarFile(classpathItem)) { manifest = getManifest(jarFile); } catch (final IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } else { final File metaDir = new File(classpathItem, "META-INF"); @@ -3525,7 +3525,7 @@ public static Manifest getManifest(File classpathItem) throws InstrumentExceptio try (FileInputStream fis = new FileInputStream(manifestFile)) { manifest = new Manifest(fis); } catch (final IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } } @@ -3538,14 +3538,14 @@ public static Manifest getManifest(File classpathItem) throws InstrumentExceptio * * @param connection {@link JarURLConnection} * @return Manifest - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static Manifest getManifest(JarURLConnection connection) throws InstrumentException { + public static Manifest getManifest(JarURLConnection connection) throws InternalException { final JarFile jarFile; try { jarFile = connection.getJarFile(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return getManifest(jarFile); } @@ -3555,13 +3555,13 @@ public static Manifest getManifest(JarURLConnection connection) throws Instrumen * * @param jarFile {@link JarURLConnection} * @return Manifest - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static Manifest getManifest(JarFile jarFile) throws InstrumentException { + public static Manifest getManifest(JarFile jarFile) throws InternalException { try { return jarFile.getManifest(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -3658,7 +3658,7 @@ private static Class doLoadClass(String name, ClassLoader classLoader, boolea // 尝试获取内部类,例如java.lang.Thread.State = java.lang.Thread$State clazz = tryLoadInnerClass(name, classLoader, isInitialized); if (null == clazz) { - throw new InstrumentException(ex); + throw new InternalException(ex); } } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/CollKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/CollKit.java index bd6b0e5054..edc3340ecf 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/CollKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/CollKit.java @@ -30,7 +30,7 @@ import org.aoju.bus.core.compare.PropertyCompare; import org.aoju.bus.core.convert.Convert; import org.aoju.bus.core.convert.ConverterRegistry; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.*; import java.lang.System; @@ -1291,12 +1291,12 @@ public static int lastIndexOf(Collection collection, Matcher matcher) } int matchIndex = -1; if (isNotEmpty(collection)) { - int index = collection.size(); + int index = 0; for (T t : collection) { if (null == matcher || matcher.match(t)) { matchIndex = index; } - index--; + index++; } } return matchIndex; @@ -1381,7 +1381,7 @@ else if (collectionType.isAssignableFrom(ArrayList.class)) { try { list = (Collection) ReflectKit.newInstance(collectionType); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } return list; @@ -2809,7 +2809,7 @@ public static void sort(List list, final boolean asc, final String... nam } } } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } return ret; }); @@ -2837,7 +2837,7 @@ public static void sort(List list, final String[] name, final boolean[] t } } } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } return ret; }); diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/FileKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/FileKit.java index d77a0ba62b..2fc7b90f67 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/FileKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/FileKit.java @@ -26,7 +26,7 @@ package org.aoju.bus.core.toolkit; import org.aoju.bus.core.collection.EnumerationIterator; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.LineHandler; import org.aoju.bus.core.io.file.FileReader; import org.aoju.bus.core.io.file.FileWriter; @@ -49,7 +49,6 @@ import java.text.DecimalFormat; import java.util.*; import java.util.function.Consumer; -import java.util.function.Predicate; import java.util.jar.JarFile; import java.util.regex.Pattern; import java.util.zip.CRC32; @@ -114,13 +113,13 @@ public static boolean isNotEmpty(File file) { * * @param dirPath 目录 * @return 是否为空 - * @throws InstrumentException IOException + * @throws InternalException IOException */ public static boolean isDirEmpty(Path dirPath) { try (DirectoryStream dirStream = Files.newDirectoryStream(dirPath)) { return false == dirStream.iterator().hasNext(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -152,7 +151,7 @@ public static File[] ls(String path) { if (file.isDirectory()) { return file.listFiles(); } - throw new InstrumentException(StringKit.format("Path [{}] is not directory!", path)); + throw new InternalException(StringKit.format("Path [{}] is not directory!", path)); } /** @@ -509,7 +508,7 @@ public static void walkFiles(Path start, int maxDepth, FileVisitor try { Files.walkFileTree(start, EnumSet.noneOf(FileVisitOption.class), maxDepth, visitor); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -606,9 +605,9 @@ public static boolean newerThan(File file, long timeMillis) { * * @param path 文件的全路径,使用POSIX风格 * @return 文件, 若路径为null, 返回null - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File touch(String path) throws InstrumentException { + public static File touch(String path) throws InternalException { if (null == path) { return null; } @@ -621,9 +620,9 @@ public static File touch(String path) throws InstrumentException { * * @param file 文件对象 * @return 文件, 若路径为null, 返回null - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File touch(File file) throws InstrumentException { + public static File touch(File file) throws InternalException { if (null == file) { return null; } @@ -632,7 +631,7 @@ public static File touch(File file) throws InstrumentException { try { file.createNewFile(); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } return file; @@ -645,9 +644,9 @@ public static File touch(File file) throws InstrumentException { * @param parent 父文件对象 * @param path 文件路径 * @return File - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File touch(File parent, String path) throws InstrumentException { + public static File touch(File parent, String path) throws InternalException { return touch(file(parent, path)); } @@ -658,9 +657,9 @@ public static File touch(File parent, String path) throws InstrumentException { * @param parent 父文件对象 * @param path 文件路径 * @return File - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File touch(String parent, String path) throws InstrumentException { + public static File touch(String parent, String path) throws InternalException { return touch(file(parent, path)); } @@ -671,9 +670,9 @@ public static File touch(String parent, String path) throws InstrumentException * * @param fullFileOrDirPath 文件或者目录的路径 * @return 成功与否 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static boolean delete(String fullFileOrDirPath) throws InstrumentException { + public static boolean delete(String fullFileOrDirPath) throws InternalException { return delete(file(fullFileOrDirPath)); } @@ -684,9 +683,9 @@ public static boolean delete(String fullFileOrDirPath) throws InstrumentExceptio * * @param file 文件对象 * @return 成功与否 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static boolean delete(File file) throws InstrumentException { + public static boolean delete(File file) throws InternalException { if (null == file || false == file.exists()) { // 如果文件不存在或已被删除,此处返回true表示删除成功 return true; @@ -707,7 +706,7 @@ public static boolean delete(File file) throws InstrumentException { // 可能遇到只读文件,无法删除.使用 file 方法删除 return file.delete(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return true; @@ -720,9 +719,9 @@ public static boolean delete(File file) throws InstrumentException { * * @param path 文件对象 * @return 成功与否 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static boolean delete(Path path) throws InstrumentException { + public static boolean delete(Path path) throws InternalException { if (Files.notExists(path)) { return true; } @@ -739,7 +738,7 @@ public static boolean delete(Path path) throws InstrumentException { } } } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return true; } @@ -751,9 +750,9 @@ public static boolean delete(Path path) throws InstrumentException { * * @param dirPath 文件夹路径 * @return 成功与否 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static boolean clean(String dirPath) throws InstrumentException { + public static boolean clean(String dirPath) throws InternalException { return clean(file(dirPath)); } @@ -764,9 +763,9 @@ public static boolean clean(String dirPath) throws InstrumentException { * * @param directory 文件夹 * @return 成功与否 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static boolean clean(File directory) throws InstrumentException { + public static boolean clean(File directory) throws InternalException { if (null == directory || directory.exists() == false || false == directory.isDirectory()) { @@ -827,7 +826,7 @@ public static Path mkdir(Path dir) { try { Files.createDirectories(dir); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } return dir; @@ -900,9 +899,9 @@ public static boolean mkdirsSafely(File dir, int tryCount, long sleepMillis) { * * @param dir 临时文件创建的所在目录 * @return 临时文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File createTempFile(File dir) throws InstrumentException { + public static File createTempFile(File dir) throws InternalException { return createTempFile("create", null, dir, true); } @@ -914,9 +913,9 @@ public static File createTempFile(File dir) throws InstrumentException { * 调用 Java 虚拟机时,可以为该系统属性赋予不同的值,但不保证对该属性的编程更改对该方法使用的临时目录有任何影响 * * @return 临时文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File createTempFile() throws InstrumentException { + public static File createTempFile() throws InternalException { return createTempFile("bus", null, null, true); } @@ -930,9 +929,9 @@ public static File createTempFile() throws InstrumentException { * @param suffix 后缀,如果null则使用默认.tmp * @param isReCreat 是否重新创建文件(删掉原来的,创建新的) * @return 临时文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File createTempFile(String suffix, boolean isReCreat) throws InstrumentException { + public static File createTempFile(String suffix, boolean isReCreat) throws InternalException { return createTempFile("bus", suffix, null, isReCreat); } @@ -947,9 +946,9 @@ public static File createTempFile(String suffix, boolean isReCreat) throws Instr * @param suffix 后缀,如果null则使用默认.tmp * @param isReCreat 是否重新创建文件(删掉原来的,创建新的) * @return 临时文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File createTempFile(String prefix, String suffix, boolean isReCreat) throws InstrumentException { + public static File createTempFile(String prefix, String suffix, boolean isReCreat) throws InternalException { return createTempFile(prefix, suffix, null, isReCreat); } @@ -960,9 +959,9 @@ public static File createTempFile(String prefix, String suffix, boolean isReCrea * @param dir 临时文件创建的所在目录 * @param isReCreat 是否重新创建文件(删掉原来的,创建新的) * @return 临时文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File createTempFile(File dir, boolean isReCreat) throws InstrumentException { + public static File createTempFile(File dir, boolean isReCreat) throws InternalException { return createTempFile("create", null, dir, isReCreat); } @@ -975,9 +974,9 @@ public static File createTempFile(File dir, boolean isReCreat) throws Instrument * @param dir 临时文件创建的所在目录 * @param isReCreat 是否重新创建文件(删掉原来的,创建新的) * @return 临时文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File createTempFile(String prefix, String suffix, File dir, boolean isReCreat) throws InstrumentException { + public static File createTempFile(String prefix, String suffix, File dir, boolean isReCreat) throws InternalException { int exceptionsCount = 0; while (true) { try { @@ -989,7 +988,7 @@ public static File createTempFile(String prefix, String suffix, File dir, boolea return file; } catch (IOException ex) { if (++exceptionsCount >= 50) { - throw new InstrumentException(ex); + throw new InternalException(ex); } } } @@ -1002,9 +1001,9 @@ public static File createTempFile(String prefix, String suffix, File dir, boolea * @param dest 目标文件或目录路径,如果为目录使用与源文件相同的文件名 * @param options {@link StandardCopyOption} * @return File - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File copyFile(String src, String dest, StandardCopyOption... options) throws InstrumentException { + public static File copyFile(String src, String dest, StandardCopyOption... options) throws InternalException { Assert.notBlank(src, "Source File path is blank !"); Assert.notBlank(dest, "Destination File path is blank !"); return copyFile(Paths.get(src), Paths.get(dest), options).toFile(); @@ -1017,16 +1016,16 @@ public static File copyFile(String src, String dest, StandardCopyOption... optio * @param dest 目标文件或目录,如果为目录使用与源文件相同的文件名 * @param options {@link StandardCopyOption} * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File copyFile(File src, File dest, StandardCopyOption... options) throws InstrumentException { + public static File copyFile(File src, File dest, StandardCopyOption... options) throws InternalException { Assert.notNull(src, "Source File is null !"); if (false == src.exists()) { - throw new InstrumentException("File not exist: " + src); + throw new InternalException("File not exist: " + src); } Assert.notNull(dest, "Destination File or directory is null !"); if (equals(src, dest)) { - throw new InstrumentException("Files '{}' and '{}' are equal", src, dest); + throw new InternalException("Files '{}' and '{}' are equal", src, dest); } return copyFile(src.toPath(), dest.toPath(), options).toFile(); } @@ -1038,9 +1037,9 @@ public static File copyFile(File src, File dest, StandardCopyOption... options) * @param dest 目标文件或目录,如果为目录使用与源文件相同的文件名 * @param options {@link StandardCopyOption} * @return Path - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static Path copyFile(Path src, Path dest, StandardCopyOption... options) throws InstrumentException { + public static Path copyFile(Path src, Path dest, StandardCopyOption... options) throws InternalException { Assert.notNull(src, "Source File is null !"); Assert.notNull(dest, "Dest File or directory is null !"); @@ -1048,7 +1047,7 @@ public static Path copyFile(Path src, Path dest, StandardCopyOption... options) try { return Files.copy(src, destPath, options); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1082,9 +1081,9 @@ public static long copyFile(final File input, final OutputStream output) throws * @param dest 目标文件或目录,目标不存在会自动创建(目录、文件都创建) * @param isOverride 是否覆盖目标文件 * @return 目标目录或文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File copyFile(File src, File dest, boolean isOverride) throws InstrumentException { + public static File copyFile(File src, File dest, boolean isOverride) throws InternalException { return FileCopier.create(src, dest).setCopyContentIfDir(true).setOnlyCopyFile(true).setOverride(isOverride).copy(); } @@ -1096,9 +1095,9 @@ public static File copyFile(File src, File dest, boolean isOverride) throws Inst * @param destPath 目标文件或目录,目标不存在会自动创建(目录、文件都创建) * @param isOverride 是否覆盖目标文件 * @return 目标目录或文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File copy(String srcPath, String destPath, boolean isOverride) throws InstrumentException { + public static File copy(String srcPath, String destPath, boolean isOverride) throws InternalException { return copy(file(srcPath), file(destPath), isOverride); } @@ -1116,9 +1115,9 @@ public static File copy(String srcPath, String destPath, boolean isOverride) thr * @param dest 目标文件或目录,目标不存在会自动创建(目录、文件都创建) * @param isOverride 是否覆盖目标文件 * @return 目标目录或文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File copy(File src, File dest, boolean isOverride) throws InstrumentException { + public static File copy(File src, File dest, boolean isOverride) throws InternalException { return FileCopier.create(src, dest).setOverride(isOverride).copy(); } @@ -1136,9 +1135,9 @@ public static File copy(File src, File dest, boolean isOverride) throws Instrume * @param dest 目标文件或目录,目标不存在会自动创建(目录、文件都创建) * @param isOverride 是否覆盖目标文件 * @return 目标目录或文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File copyContent(File src, File dest, boolean isOverride) throws InstrumentException { + public static File copyContent(File src, File dest, boolean isOverride) throws InternalException { return FileCopier.create(src, dest).setCopyContentIfDir(true).setOverride(isOverride).copy(); } @@ -1212,9 +1211,9 @@ public static File rename(File file, String newName, boolean isRetainExt, boolea * @param src 源文件或者目录 * @param target 目标文件或者目录 * @param isOverride 是否覆盖目标,只有目标为文件才覆盖 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void move(File src, File target, boolean isOverride) throws InstrumentException { + public static void move(File src, File target, boolean isOverride) throws InternalException { move(src.toPath(), target.toPath(), isOverride); } @@ -1239,7 +1238,7 @@ public static Path move(Path src, Path target, boolean isOverride) { } catch (IOException e) { if (e instanceof FileAlreadyExistsException) { // 目标文件已存在,直接抛出异常 - throw new InstrumentException(e); + throw new InternalException(e); } // 移动失败,可能是跨分区移动导致的,采用递归移动方式 try { @@ -1247,7 +1246,7 @@ public static Path move(Path src, Path target, boolean isOverride) { // 移动后空目录没有删除, delete(src); } catch (IOException e2) { - throw new InstrumentException(e2); + throw new InternalException(e2); } return target; } @@ -1266,7 +1265,7 @@ public static String getCanonicalPath(File file) { try { return file.getCanonicalPath(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1359,10 +1358,10 @@ public static boolean isAbsolutePath(String path) { * @param file1 文件1 * @param file2 文件2 * @return 是否相同 - * @throws InstrumentException 异常 + * @throws InternalException 异常 * @see Files#isSameFile(Path, Path) */ - public static boolean equals(File file1, File file2) throws InstrumentException { + public static boolean equals(File file1, File file2) throws InternalException { Assert.notNull(file1); Assert.notNull(file2); if (false == file1.exists() || false == file2.exists()) { @@ -1373,7 +1372,7 @@ public static boolean equals(File file1, File file2) throws InstrumentException try { return Files.isSameFile(file1.toPath(), file2.toPath()); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1397,7 +1396,7 @@ public static String readFile(File file) { reader.close(); return all; } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { if (null != reader) { try { @@ -1415,9 +1414,9 @@ public static String readFile(File file) { * * @param path 相对ClassPath的目录或者绝对路径目录 * @return 文件路径列表(如果是jar中的文件, 则给定类似.jar ! / xxx / xxx的路径) - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static List listFileNames(String path) throws InstrumentException { + public static List listFileNames(String path) throws InternalException { if (null == path) { return new ArrayList<>(0); } @@ -1444,7 +1443,7 @@ public static List listFileNames(String path) throws InstrumentException // 防止出现jar!/org/aoju/这类路径导致文件找不到 return ZipKit.listFileNames(jarFile, StringKit.removePrefix(path.substring(index + 1), Symbol.SLASH)); } catch (IOException e) { - throw new InstrumentException(StringKit.format("Can not read file path of [{}]", path), e); + throw new InternalException(StringKit.format("Can not read file path of [{}]", path), e); } finally { IoKit.close(jarFile); } @@ -1614,9 +1613,9 @@ public static boolean isSymlink(File file) { * @param file1 文件1 * @param file2 文件2 * @return 两个文件内容一致返回true, 否则false - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static boolean contentEquals(File file1, File file2) throws InstrumentException { + public static boolean contentEquals(File file1, File file2) throws InternalException { boolean file1Exists = file1.exists(); if (file1Exists != file2.exists()) { return false; @@ -1629,7 +1628,7 @@ public static boolean contentEquals(File file1, File file2) throws InstrumentExc if (file1.isDirectory() || file2.isDirectory()) { // 不比较目录 - throw new InstrumentException("Can't compare directories, only file"); + throw new InternalException("Can't compare directories, only file"); } if (file1.length() != file2.length()) { @@ -1664,9 +1663,9 @@ public static boolean contentEquals(File file1, File file2) throws InstrumentExc * @param file2 文件2 * @param charset 编码,null表示使用平台默认编码 两个文件内容一致返回true,否则false * @return the boolean - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static boolean contentEqualsIgnoreEOL(File file1, File file2, java.nio.charset.Charset charset) throws InstrumentException { + public static boolean contentEqualsIgnoreEOL(File file1, File file2, java.nio.charset.Charset charset) throws InternalException { boolean file1Exists = file1.exists(); if (file1Exists != file2.exists()) { return false; @@ -1679,7 +1678,7 @@ public static boolean contentEqualsIgnoreEOL(File file1, File file2, java.nio.ch if (file1.isDirectory() || file2.isDirectory()) { // 不比较目录 - throw new InstrumentException("Can't compare directories, only file"); + throw new InternalException("Can't compare directories, only file"); } if (equals(file1, file2)) { @@ -1895,7 +1894,7 @@ public static String subPath(String rootDir, File file) { try { return subPath(rootDir, file.getCanonicalPath()); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -2157,10 +2156,10 @@ public static boolean endsWith(File file, String suffix) { * * @param file 文件 {@link File} * @return 类型, 文件的扩展名, 未找到为null - * @throws InstrumentException 异常 + * @throws InternalException 异常 * @see FileType#getType(File) */ - public static String getType(File file) throws InstrumentException { + public static String getType(File file) throws InternalException { return FileType.getType(file); } @@ -2170,9 +2169,9 @@ public static String getType(File file) throws InstrumentException { * @param path 文件路径{@link Path} * @param isFollowLinks 是否跟踪到软链对应的真实路径 * @return {@link BasicFileAttributes} - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static BasicFileAttributes getAttributes(Path path, boolean isFollowLinks) throws InstrumentException { + public static BasicFileAttributes getAttributes(Path path, boolean isFollowLinks) throws InternalException { if (null == path) { return null; } @@ -2181,7 +2180,7 @@ public static BasicFileAttributes getAttributes(Path path, boolean isFollowLinks try { return Files.readAttributes(path, BasicFileAttributes.class, options); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -2190,13 +2189,13 @@ public static BasicFileAttributes getAttributes(Path path, boolean isFollowLinks * * @param path Path * @return 输入流 - * @throws InstrumentException 文件未找到 + * @throws InternalException 文件未找到 */ - public static BufferedInputStream getInputStream(Path path) throws InstrumentException { + public static BufferedInputStream getInputStream(Path path) throws InternalException { try { return new BufferedInputStream(Files.newInputStream(path)); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -2205,9 +2204,9 @@ public static BufferedInputStream getInputStream(Path path) throws InstrumentExc * * @param file 文件 * @return 输入流 - * @throws InstrumentException 文件未找到 + * @throws InternalException 文件未找到 */ - public static BufferedInputStream getInputStream(File file) throws InstrumentException { + public static BufferedInputStream getInputStream(File file) throws InternalException { return new BufferedInputStream(IoKit.toStream(file)); } @@ -2216,9 +2215,9 @@ public static BufferedInputStream getInputStream(File file) throws InstrumentExc * * @param path 文件路径 * @return 输入流 - * @throws InstrumentException 文件未找到 + * @throws InternalException 文件未找到 */ - public static BufferedInputStream getInputStream(String path) throws InstrumentException { + public static BufferedInputStream getInputStream(String path) throws InternalException { return getInputStream(file(path)); } @@ -2227,13 +2226,13 @@ public static BufferedInputStream getInputStream(String path) throws InstrumentE * * @param file 文件 * @return 输入流 - * @throws InstrumentException 文件未找到 + * @throws InternalException 文件未找到 */ - public static BOMInputStream getBOMInputStream(File file) throws InstrumentException { + public static BOMInputStream getBOMInputStream(File file) throws InternalException { try { return new BOMInputStream(new FileInputStream(file)); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -2252,9 +2251,9 @@ public static BufferedReader getBOMReader(File file) { * * @param path 文件Path * @return BufferedReader对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static BufferedReader getReader(Path path) throws InstrumentException { + public static BufferedReader getReader(Path path) throws InternalException { return getReader(path, Charset.UTF_8); } @@ -2263,9 +2262,9 @@ public static BufferedReader getReader(Path path) throws InstrumentException { * * @param file 文件 * @return BufferedReader对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static BufferedReader getReader(File file) throws InstrumentException { + public static BufferedReader getReader(File file) throws InternalException { return getReader(file, Charset.UTF_8); } @@ -2274,9 +2273,9 @@ public static BufferedReader getReader(File file) throws InstrumentException { * * @param path 文件路径 * @return BufferedReader对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static BufferedReader getReader(String path) throws InstrumentException { + public static BufferedReader getReader(String path) throws InternalException { return getReader(path, Charset.UTF_8); } @@ -2286,9 +2285,9 @@ public static BufferedReader getReader(String path) throws InstrumentException { * @param path 文件Path * @param charset 字符集 * @return BufferedReader对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static BufferedReader getReader(Path path, java.nio.charset.Charset charset) throws InstrumentException { + public static BufferedReader getReader(Path path, java.nio.charset.Charset charset) throws InternalException { return IoKit.getReader(getInputStream(path), charset); } @@ -2298,9 +2297,9 @@ public static BufferedReader getReader(Path path, java.nio.charset.Charset chars * @param file 文件 * @param charsetName 字符集 * @return BufferedReader对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static BufferedReader getReader(File file, String charsetName) throws InstrumentException { + public static BufferedReader getReader(File file, String charsetName) throws InternalException { return IoKit.getReader(getInputStream(file), charsetName); } @@ -2310,9 +2309,9 @@ public static BufferedReader getReader(File file, String charsetName) throws Ins * @param file 文件 * @param charset 字符集 * @return BufferedReader对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static BufferedReader getReader(File file, java.nio.charset.Charset charset) throws InstrumentException { + public static BufferedReader getReader(File file, java.nio.charset.Charset charset) throws InternalException { return IoKit.getReader(getInputStream(file), charset); } @@ -2322,9 +2321,9 @@ public static BufferedReader getReader(File file, java.nio.charset.Charset chars * @param path 绝对路径 * @param charsetName 字符集 * @return BufferedReader对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static BufferedReader getReader(String path, String charsetName) throws InstrumentException { + public static BufferedReader getReader(String path, String charsetName) throws InternalException { return getReader(file(path), charsetName); } @@ -2334,9 +2333,9 @@ public static BufferedReader getReader(String path, String charsetName) throws I * @param path 绝对路径 * @param charset 字符集 * @return BufferedReader对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static BufferedReader getReader(String path, java.nio.charset.Charset charset) throws InstrumentException { + public static BufferedReader getReader(String path, java.nio.charset.Charset charset) throws InternalException { return getReader(file(path), charset); } @@ -2346,9 +2345,9 @@ public static BufferedReader getReader(String path, java.nio.charset.Charset cha * * @param file 文件 * @return 字节码 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static byte[] readBytes(File file) throws InstrumentException { + public static byte[] readBytes(File file) throws InternalException { return FileReader.create(file).readBytes(); } @@ -2358,9 +2357,9 @@ public static byte[] readBytes(File file) throws InstrumentException { * * @param filePath 文件路径 * @return 字节码 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static byte[] readBytes(String filePath) throws InstrumentException { + public static byte[] readBytes(String filePath) throws InternalException { return readBytes(file(filePath)); } @@ -2369,9 +2368,9 @@ public static byte[] readBytes(String filePath) throws InstrumentException { * * @param file 文件 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String readString(File file) throws InstrumentException { + public static String readString(File file) throws InternalException { return readString(file, Charset.UTF_8); } @@ -2380,9 +2379,9 @@ public static String readString(File file) throws InstrumentException { * * @param path 文件路径 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String readString(String path) throws InstrumentException { + public static String readString(String path) throws InternalException { return readString(path, Charset.UTF_8); } @@ -2392,9 +2391,9 @@ public static String readString(String path) throws InstrumentException { * @param file 文件 * @param charsetName 字符集 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String readString(File file, String charsetName) throws InstrumentException { + public static String readString(File file, String charsetName) throws InternalException { return readString(file, Charset.charset(charsetName)); } @@ -2404,9 +2403,9 @@ public static String readString(File file, String charsetName) throws Instrument * @param file 文件 * @param charset 字符集 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String readString(File file, java.nio.charset.Charset charset) throws InstrumentException { + public static String readString(File file, java.nio.charset.Charset charset) throws InternalException { return FileReader.create(file, charset).readString(); } @@ -2416,9 +2415,9 @@ public static String readString(File file, java.nio.charset.Charset charset) thr * @param path 文件路径 * @param charsetName 字符集 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String readString(String path, String charsetName) throws InstrumentException { + public static String readString(String path, String charsetName) throws InternalException { return readString(file(path), charsetName); } @@ -2428,9 +2427,9 @@ public static String readString(String path, String charsetName) throws Instrume * @param path 文件路径 * @param charset 字符集 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String readString(String path, java.nio.charset.Charset charset) throws InstrumentException { + public static String readString(String path, java.nio.charset.Charset charset) throws InternalException { return readString(file(path), charset); } @@ -2440,9 +2439,9 @@ public static String readString(String path, java.nio.charset.Charset charset) t * @param url 文件URL * @param charset 字符集 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String readString(URL url, String charset) throws InstrumentException { + public static String readString(URL url, String charset) throws InternalException { if (null == url) { throw new NullPointerException("Empty url provided!"); } @@ -2452,7 +2451,7 @@ public static String readString(URL url, String charset) throws InstrumentExcept in = url.openStream(); return IoKit.read(in, charset); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(in); } @@ -2465,9 +2464,9 @@ public static String readString(URL url, String charset) throws InstrumentExcept * @param path 文件路径 * @param collection 集合 * @return 文件中的每行内容的集合 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static > T readLines(String path, T collection) throws InstrumentException { + public static > T readLines(String path, T collection) throws InternalException { return readLines(path, Charset.UTF_8, collection); } @@ -2479,9 +2478,9 @@ public static > T readLines(String path, T collecti * @param charset 字符集 * @param collection 集合 * @return 文件中的每行内容的集合 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static > T readLines(String path, String charset, T collection) throws InstrumentException { + public static > T readLines(String path, String charset, T collection) throws InternalException { return readLines(file(path), charset, collection); } @@ -2493,9 +2492,9 @@ public static > T readLines(String path, String cha * @param charset 字符集 * @param collection 集合 * @return 文件中的每行内容的集合 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static > T readLines(String path, java.nio.charset.Charset charset, T collection) throws InstrumentException { + public static > T readLines(String path, java.nio.charset.Charset charset, T collection) throws InternalException { return readLines(file(path), charset, collection); } @@ -2506,9 +2505,9 @@ public static > T readLines(String path, java.nio.c * @param file 文件路径 * @param collection 集合 * @return 文件中的每行内容的集合 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static > T readLines(File file, T collection) throws InstrumentException { + public static > T readLines(File file, T collection) throws InternalException { return readLines(file, Charset.UTF_8, collection); } @@ -2520,9 +2519,9 @@ public static > T readLines(File file, T collection * @param charset 字符集 * @param collection 集合 * @return 文件中的每行内容的集合 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static > T readLines(File file, String charset, T collection) throws InstrumentException { + public static > T readLines(File file, String charset, T collection) throws InternalException { return FileReader.create(file, Charset.charset(charset)).readLines(collection); } @@ -2534,9 +2533,9 @@ public static > T readLines(File file, String chars * @param charset 字符集 * @param collection 集合 * @return 文件中的每行内容的集合 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static > T readLines(File file, java.nio.charset.Charset charset, T collection) throws InstrumentException { + public static > T readLines(File file, java.nio.charset.Charset charset, T collection) throws InternalException { return FileReader.create(file, charset).readLines(collection); } @@ -2547,9 +2546,9 @@ public static > T readLines(File file, java.nio.cha * @param url 文件的URL * @param collection 集合 * @return 文件中的每行内容的集合 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static > T readLines(URL url, T collection) throws InstrumentException { + public static > T readLines(URL url, T collection) throws InternalException { return readLines(url, Charset.UTF_8, collection); } @@ -2561,9 +2560,9 @@ public static > T readLines(URL url, T collection) * @param charsetName 字符集 * @param collection 集合 * @return 文件中的每行内容的集合 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static > T readLines(URL url, String charsetName, T collection) throws InstrumentException { + public static > T readLines(URL url, String charsetName, T collection) throws InternalException { return readLines(url, Charset.charset(charsetName), collection); } @@ -2575,15 +2574,15 @@ public static > T readLines(URL url, String charset * @param charset 字符集 * @param collection 集合 * @return 文件中的每行内容的集合 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static > T readLines(URL url, java.nio.charset.Charset charset, T collection) throws InstrumentException { + public static > T readLines(URL url, java.nio.charset.Charset charset, T collection) throws InternalException { InputStream in = null; try { in = url.openStream(); return IoKit.readLines(in, charset, collection); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(in); } @@ -2594,9 +2593,9 @@ public static > T readLines(URL url, java.nio.chars * * @param url 文件的URL * @return 文件中的每行内容的集合List - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static List readLines(URL url) throws InstrumentException { + public static List readLines(URL url) throws InternalException { return readLines(url, Charset.UTF_8); } @@ -2606,9 +2605,9 @@ public static List readLines(URL url) throws InstrumentException { * @param url 文件的URL * @param charset 字符集 * @return 文件中的每行内容的集合List - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static List readLines(URL url, String charset) throws InstrumentException { + public static List readLines(URL url, String charset) throws InternalException { return readLines(url, charset, new ArrayList<>()); } @@ -2618,9 +2617,9 @@ public static List readLines(URL url, String charset) throws InstrumentE * @param url 文件的URL * @param charset 字符集 * @return 文件中的每行内容的集合List - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static List readLines(URL url, java.nio.charset.Charset charset) throws InstrumentException { + public static List readLines(URL url, java.nio.charset.Charset charset) throws InternalException { return readLines(url, charset, new ArrayList<>()); } @@ -2629,9 +2628,9 @@ public static List readLines(URL url, java.nio.charset.Charset charset) * * @param path 文件路径 * @return 文件中的每行内容的集合List - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static List readLines(String path) throws InstrumentException { + public static List readLines(String path) throws InternalException { return readLines(path, Charset.UTF_8); } @@ -2641,9 +2640,9 @@ public static List readLines(String path) throws InstrumentException { * @param path 文件路径 * @param charset 字符集 * @return 文件中的每行内容的集合List - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static List readLines(String path, String charset) throws InstrumentException { + public static List readLines(String path, String charset) throws InternalException { return readLines(path, charset, new ArrayList<>()); } @@ -2653,9 +2652,9 @@ public static List readLines(String path, String charset) throws Instrum * @param path 文件路径 * @param charset 字符集 * @return 文件中的每行内容的集合List - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static List readLines(String path, java.nio.charset.Charset charset) throws InstrumentException { + public static List readLines(String path, java.nio.charset.Charset charset) throws InternalException { return readLines(path, charset, new ArrayList<>()); } @@ -2664,9 +2663,9 @@ public static List readLines(String path, java.nio.charset.Charset chars * * @param file 文件 * @return 文件中的每行内容的集合List - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static List readLines(File file) throws InstrumentException { + public static List readLines(File file) throws InternalException { return readLines(file, Charset.UTF_8); } @@ -2676,9 +2675,9 @@ public static List readLines(File file) throws InstrumentException { * @param file 文件 * @param charset 字符集 * @return 文件中的每行内容的集合List - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static List readLines(File file, String charset) throws InstrumentException { + public static List readLines(File file, String charset) throws InternalException { return readLines(file, charset, new ArrayList<>()); } @@ -2688,9 +2687,9 @@ public static List readLines(File file, String charset) throws Instrumen * @param file 文件 * @param charset 字符集 * @return 文件中的每行内容的集合List - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static List readLines(File file, java.nio.charset.Charset charset) throws InstrumentException { + public static List readLines(File file, java.nio.charset.Charset charset) throws InternalException { return readLines(file, charset, new ArrayList<>()); } @@ -2699,9 +2698,9 @@ public static List readLines(File file, java.nio.charset.Charset charset * * @param file 文件 * @param lineHandler {@link LineHandler}行处理器 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static void readLines(File file, LineHandler lineHandler) throws InstrumentException { + public static void readLines(File file, LineHandler lineHandler) throws InternalException { readLines(file, Charset.UTF_8, lineHandler); } @@ -2711,9 +2710,9 @@ public static void readLines(File file, LineHandler lineHandler) throws Instrume * @param file 文件 * @param charset 编码 * @param lineHandler {@link LineHandler}行处理器 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static void readLines(File file, java.nio.charset.Charset charset, LineHandler lineHandler) throws InstrumentException { + public static void readLines(File file, java.nio.charset.Charset charset, LineHandler lineHandler) throws InternalException { FileReader.create(file, charset).readLines(lineHandler); } @@ -2723,7 +2722,7 @@ public static void readLines(File file, java.nio.charset.Charset charset, LineHa * @param file {@link RandomAccessFile}文件 * @param charset 编码 * @param lineHandler {@link LineHandler}行处理器 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ public static void readLines(RandomAccessFile file, java.nio.charset.Charset charset, LineHandler lineHandler) { String line; @@ -2732,7 +2731,7 @@ public static void readLines(RandomAccessFile file, java.nio.charset.Charset cha lineHandler.handle(Charset.convert(line, Charset.ISO_8859_1, charset)); } } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -2762,7 +2761,7 @@ public static String readLine(RandomAccessFile file, java.nio.charset.Charset ch try { line = file.readLine(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (null != line) { return Charset.convert(line, Charset.ISO_8859_1, charset); @@ -2778,9 +2777,9 @@ public static String readLine(RandomAccessFile file, java.nio.charset.Charset ch * @param readerHandler Reader处理类 * @param path 文件的绝对路径 * @return 从文件中load出的数据 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static T load(String path, FileReader.ReaderHandler readerHandler) throws InstrumentException { + public static T load(String path, FileReader.ReaderHandler readerHandler) throws InternalException { return load(path, Charset.UTF_8, readerHandler); } @@ -2792,9 +2791,9 @@ public static T load(String path, FileReader.ReaderHandler readerHandler) * @param path 文件的绝对路径 * @param charset 字符集 * @return 从文件中load出的数据 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static T load(String path, String charset, FileReader.ReaderHandler readerHandler) throws InstrumentException { + public static T load(String path, String charset, FileReader.ReaderHandler readerHandler) throws InternalException { return FileReader.create(file(path), Charset.charset(charset)).read(readerHandler); } @@ -2806,9 +2805,9 @@ public static T load(String path, String charset, FileReader.ReaderHandler T load(String path, java.nio.charset.Charset charset, FileReader.ReaderHandler readerHandler) throws InstrumentException { + public static T load(String path, java.nio.charset.Charset charset, FileReader.ReaderHandler readerHandler) throws InternalException { return FileReader.create(file(path), charset).read(readerHandler); } @@ -2819,9 +2818,9 @@ public static T load(String path, java.nio.charset.Charset charset, FileRead * @param readerHandler Reader处理类 * @param file 文件 * @return 从文件中load出的数据 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static T load(File file, FileReader.ReaderHandler readerHandler) throws InstrumentException { + public static T load(File file, FileReader.ReaderHandler readerHandler) throws InternalException { return load(file, Charset.UTF_8, readerHandler); } @@ -2833,9 +2832,9 @@ public static T load(File file, FileReader.ReaderHandler readerHandler) t * @param file 文件 * @param charset 字符集 * @return 从文件中load出的数据 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static T load(File file, java.nio.charset.Charset charset, FileReader.ReaderHandler readerHandler) throws InstrumentException { + public static T load(File file, java.nio.charset.Charset charset, FileReader.ReaderHandler readerHandler) throws InternalException { return FileReader.create(file, charset).read(readerHandler); } @@ -2844,13 +2843,13 @@ public static T load(File file, java.nio.charset.Charset charset, FileReader * * @param file 文件 * @return 输出流对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static BufferedOutputStream getOutputStream(File file) throws InstrumentException { + public static BufferedOutputStream getOutputStream(File file) throws InternalException { try { return new BufferedOutputStream(new FileOutputStream(touch(file))); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -2859,9 +2858,9 @@ public static BufferedOutputStream getOutputStream(File file) throws InstrumentE * * @param path 输出到的文件路径,绝对路径 * @return 输出流对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static BufferedOutputStream getOutputStream(String path) throws InstrumentException { + public static BufferedOutputStream getOutputStream(String path) throws InternalException { return getOutputStream(touch(path)); } @@ -2872,9 +2871,9 @@ public static BufferedOutputStream getOutputStream(String path) throws Instrumen * @param charsetName 字符集 * @param isAppend 是否追加 * @return BufferedReader对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static BufferedWriter getWriter(String path, String charsetName, boolean isAppend) throws InstrumentException { + public static BufferedWriter getWriter(String path, String charsetName, boolean isAppend) throws InternalException { return getWriter(touch(path), java.nio.charset.Charset.forName(charsetName), isAppend); } @@ -2885,9 +2884,9 @@ public static BufferedWriter getWriter(String path, String charsetName, boolean * @param charset 字符集 * @param isAppend 是否追加 * @return BufferedReader对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static BufferedWriter getWriter(String path, java.nio.charset.Charset charset, boolean isAppend) throws InstrumentException { + public static BufferedWriter getWriter(String path, java.nio.charset.Charset charset, boolean isAppend) throws InternalException { return getWriter(touch(path), charset, isAppend); } @@ -2898,9 +2897,9 @@ public static BufferedWriter getWriter(String path, java.nio.charset.Charset cha * @param charsetName 字符集 * @param isAppend 是否追加 * @return BufferedReader对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static BufferedWriter getWriter(File file, String charsetName, boolean isAppend) throws InstrumentException { + public static BufferedWriter getWriter(File file, String charsetName, boolean isAppend) throws InternalException { return getWriter(file, java.nio.charset.Charset.forName(charsetName), isAppend); } @@ -2911,9 +2910,9 @@ public static BufferedWriter getWriter(File file, String charsetName, boolean is * @param charset 字符集 * @param isAppend 是否追加 * @return BufferedReader对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static BufferedWriter getWriter(File file, java.nio.charset.Charset charset, boolean isAppend) throws InstrumentException { + public static BufferedWriter getWriter(File file, java.nio.charset.Charset charset, boolean isAppend) throws InternalException { return FileWriter.create(file, charset).getWriter(isAppend); } @@ -2924,9 +2923,9 @@ public static BufferedWriter getWriter(File file, java.nio.charset.Charset chars * @param charset 字符集 * @param isAppend 是否追加 * @return 打印对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static PrintWriter getPrintWriter(String path, String charset, boolean isAppend) throws InstrumentException { + public static PrintWriter getPrintWriter(String path, String charset, boolean isAppend) throws InternalException { return new PrintWriter(getWriter(path, charset, isAppend)); } @@ -2937,9 +2936,9 @@ public static PrintWriter getPrintWriter(String path, String charset, boolean is * @param charset 字符集 * @param isAppend 是否追加 * @return 打印对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static PrintWriter getPrintWriter(String path, java.nio.charset.Charset charset, boolean isAppend) throws InstrumentException { + public static PrintWriter getPrintWriter(String path, java.nio.charset.Charset charset, boolean isAppend) throws InternalException { return new PrintWriter(getWriter(path, charset, isAppend)); } @@ -2950,9 +2949,9 @@ public static PrintWriter getPrintWriter(String path, java.nio.charset.Charset c * @param charset 字符集 * @param isAppend 是否追加 * @return 打印对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static PrintWriter getPrintWriter(File file, String charset, boolean isAppend) throws InstrumentException { + public static PrintWriter getPrintWriter(File file, String charset, boolean isAppend) throws InternalException { return new PrintWriter(getWriter(file, charset, isAppend)); } @@ -2963,9 +2962,9 @@ public static PrintWriter getPrintWriter(File file, String charset, boolean isAp * @param charset 字符集 * @param isAppend 是否追加 * @return 打印对象 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static PrintWriter getPrintWriter(File file, java.nio.charset.Charset charset, boolean isAppend) throws InstrumentException { + public static PrintWriter getPrintWriter(File file, java.nio.charset.Charset charset, boolean isAppend) throws InternalException { return new PrintWriter(getWriter(file, charset, isAppend)); } @@ -2990,9 +2989,9 @@ public static String getLineSeparator() { * @param content 写入的内容 * @param path 文件路径 * @return 写入的文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeString(String content, String path) throws InstrumentException { + public static File writeString(String content, String path) throws InternalException { return writeString(content, path, Charset.UTF_8); } @@ -3002,9 +3001,9 @@ public static File writeString(String content, String path) throws InstrumentExc * @param content 写入的内容 * @param file 文件 * @return 写入的文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeString(String content, File file) throws InstrumentException { + public static File writeString(String content, File file) throws InternalException { return writeString(content, file, Charset.UTF_8); } @@ -3015,9 +3014,9 @@ public static File writeString(String content, File file) throws InstrumentExcep * @param path 文件路径 * @param charset 字符集 * @return 写入的文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeString(String content, String path, String charset) throws InstrumentException { + public static File writeString(String content, String path, String charset) throws InternalException { return writeString(content, touch(path), charset); } @@ -3028,9 +3027,9 @@ public static File writeString(String content, String path, String charset) thro * @param path 文件路径 * @param charset 字符集 * @return 写入的文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeString(String content, String path, java.nio.charset.Charset charset) throws InstrumentException { + public static File writeString(String content, String path, java.nio.charset.Charset charset) throws InternalException { return writeString(content, touch(path), charset); } @@ -3041,9 +3040,9 @@ public static File writeString(String content, String path, java.nio.charset.Cha * @param file 文件 * @param charset 字符集 * @return 被写入的文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeString(String content, File file, String charset) throws InstrumentException { + public static File writeString(String content, File file, String charset) throws InternalException { return FileWriter.create(file, Charset.charset(charset)).write(content); } @@ -3054,9 +3053,9 @@ public static File writeString(String content, File file, String charset) throws * @param file 文件 * @param charset 字符集 * @return 被写入的文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeString(String content, File file, java.nio.charset.Charset charset) throws InstrumentException { + public static File writeString(String content, File file, java.nio.charset.Charset charset) throws InternalException { return FileWriter.create(file, charset).write(content); } @@ -3066,9 +3065,9 @@ public static File writeString(String content, File file, java.nio.charset.Chars * @param content 写入的内容 * @param path 文件路径 * @return 写入的文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File appendString(String content, String path) throws InstrumentException { + public static File appendString(String content, String path) throws InternalException { return appendString(content, path, Charset.UTF_8); } @@ -3079,9 +3078,9 @@ public static File appendString(String content, String path) throws InstrumentEx * @param path 文件路径 * @param charset 字符集 * @return 写入的文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File appendString(String content, String path, String charset) throws InstrumentException { + public static File appendString(String content, String path, String charset) throws InternalException { return appendString(content, touch(path), charset); } @@ -3092,9 +3091,9 @@ public static File appendString(String content, String path, String charset) thr * @param path 文件路径 * @param charset 字符集 * @return 写入的文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File appendString(String content, String path, java.nio.charset.Charset charset) throws InstrumentException { + public static File appendString(String content, String path, java.nio.charset.Charset charset) throws InternalException { return appendString(content, touch(path), charset); } @@ -3104,9 +3103,9 @@ public static File appendString(String content, String path, java.nio.charset.Ch * @param content 写入的内容 * @param file 文件 * @return 写入的文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File appendString(String content, File file) throws InstrumentException { + public static File appendString(String content, File file) throws InternalException { return appendString(content, file, Charset.UTF_8); } @@ -3117,9 +3116,9 @@ public static File appendString(String content, File file) throws InstrumentExce * @param file 文件 * @param charset 字符集 * @return 写入的文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File appendString(String content, File file, String charset) throws InstrumentException { + public static File appendString(String content, File file, String charset) throws InternalException { return FileWriter.create(file, Charset.charset(charset)).append(content); } @@ -3130,9 +3129,9 @@ public static File appendString(String content, File file, String charset) throw * @param file 文件 * @param charset 字符集 * @return 写入的文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File appendString(String content, File file, java.nio.charset.Charset charset) throws InstrumentException { + public static File appendString(String content, File file, java.nio.charset.Charset charset) throws InternalException { return FileWriter.create(file, charset).append(content); } @@ -3143,9 +3142,9 @@ public static File appendString(String content, File file, java.nio.charset.Char * @param list 列表 * @param path 绝对路径 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeLines(Collection list, String path) throws InstrumentException { + public static File writeLines(Collection list, String path) throws InternalException { return writeLines(list, path, Charset.UTF_8); } @@ -3156,9 +3155,9 @@ public static File writeLines(Collection list, String path) throws Instru * @param list 列表 * @param file 绝对路径 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeLines(Collection list, File file) throws InstrumentException { + public static File writeLines(Collection list, File file) throws InternalException { return writeLines(list, file, Charset.UTF_8); } @@ -3170,9 +3169,9 @@ public static File writeLines(Collection list, File file) throws Instrume * @param path 绝对路径 * @param charset 字符集 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeLines(Collection list, String path, String charset) throws InstrumentException { + public static File writeLines(Collection list, String path, String charset) throws InternalException { return writeLines(list, path, charset, false); } @@ -3184,9 +3183,9 @@ public static File writeLines(Collection list, String path, String charse * @param path 绝对路径 * @param charset 字符集 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeLines(Collection list, String path, java.nio.charset.Charset charset) throws InstrumentException { + public static File writeLines(Collection list, String path, java.nio.charset.Charset charset) throws InternalException { return writeLines(list, path, charset, false); } @@ -3198,9 +3197,9 @@ public static File writeLines(Collection list, String path, java.nio.char * @param file 文件 * @param charset 字符集 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeLines(Collection list, File file, String charset) throws InstrumentException { + public static File writeLines(Collection list, File file, String charset) throws InternalException { return writeLines(list, file, charset, false); } @@ -3212,9 +3211,9 @@ public static File writeLines(Collection list, File file, String charset) * @param file 文件 * @param charset 字符集 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeLines(Collection list, File file, java.nio.charset.Charset charset) throws InstrumentException { + public static File writeLines(Collection list, File file, java.nio.charset.Charset charset) throws InternalException { return writeLines(list, file, charset, false); } @@ -3225,9 +3224,9 @@ public static File writeLines(Collection list, File file, java.nio.charse * @param list 列表 * @param file 文件 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File appendLines(Collection list, File file) throws InstrumentException { + public static File appendLines(Collection list, File file) throws InternalException { return appendLines(list, file, Charset.UTF_8); } @@ -3238,9 +3237,9 @@ public static File appendLines(Collection list, File file) throws Instrum * @param list 列表 * @param path 文件路径 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File appendLines(Collection list, String path) throws InstrumentException { + public static File appendLines(Collection list, String path) throws InternalException { return appendLines(list, path, Charset.UTF_8); } @@ -3252,9 +3251,9 @@ public static File appendLines(Collection list, String path) throws Instr * @param path 绝对路径 * @param charset 字符集 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File appendLines(Collection list, String path, String charset) throws InstrumentException { + public static File appendLines(Collection list, String path, String charset) throws InternalException { return writeLines(list, path, charset, true); } @@ -3271,9 +3270,9 @@ public static File appendLines(Collection list, String path, String chars * @param file 文件 * @param charset 字符集 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File appendLines(Collection list, File file, String charset) throws InstrumentException { + public static File appendLines(Collection list, File file, String charset) throws InternalException { return writeLines(list, file, charset, true); } @@ -3285,9 +3284,9 @@ public static File appendLines(Collection list, File file, String charset * @param path 绝对路径 * @param charset 字符集 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File appendLines(Collection list, String path, java.nio.charset.Charset charset) throws InstrumentException { + public static File appendLines(Collection list, String path, java.nio.charset.Charset charset) throws InternalException { return writeLines(list, path, charset, true); } @@ -3299,9 +3298,9 @@ public static File appendLines(Collection list, String path, java.nio.cha * @param file 文件 * @param charset 字符集 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File appendLines(Collection list, File file, java.nio.charset.Charset charset) throws InstrumentException { + public static File appendLines(Collection list, File file, java.nio.charset.Charset charset) throws InternalException { return writeLines(list, file, charset, true); } @@ -3314,9 +3313,9 @@ public static File appendLines(Collection list, File file, java.nio.chars * @param charset 字符集 * @param isAppend 是否追加 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeLines(Collection list, String path, String charset, boolean isAppend) throws InstrumentException { + public static File writeLines(Collection list, String path, String charset, boolean isAppend) throws InternalException { return writeLines(list, file(path), charset, isAppend); } @@ -3329,9 +3328,9 @@ public static File writeLines(Collection list, String path, String charse * @param charset 字符集 * @param isAppend 是否追加 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeLines(Collection list, String path, java.nio.charset.Charset charset, boolean isAppend) throws InstrumentException { + public static File writeLines(Collection list, String path, java.nio.charset.Charset charset, boolean isAppend) throws InternalException { return writeLines(list, file(path), charset, isAppend); } @@ -3344,9 +3343,9 @@ public static File writeLines(Collection list, String path, java.nio.char * @param charset 字符集 * @param isAppend 是否追加 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeLines(Collection list, File file, String charset, boolean isAppend) throws InstrumentException { + public static File writeLines(Collection list, File file, String charset, boolean isAppend) throws InternalException { return FileWriter.create(file, Charset.charset(charset)).writeLines(list, isAppend); } @@ -3359,9 +3358,9 @@ public static File writeLines(Collection list, File file, String charset, * @param charset 字符集 * @param isAppend 是否追加 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeLines(Collection list, File file, java.nio.charset.Charset charset, boolean isAppend) throws InstrumentException { + public static File writeLines(Collection list, File file, java.nio.charset.Charset charset, boolean isAppend) throws InternalException { return FileWriter.create(file, charset).writeLines(list, isAppend); } @@ -3373,9 +3372,9 @@ public static File writeLines(Collection list, File file, java.nio.charse * @param kvSeparator 键和值之间的分隔符,如果传入null使用默认分隔符" = " * @param isAppend 是否追加 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeMap(Map map, File file, String kvSeparator, boolean isAppend) throws InstrumentException { + public static File writeMap(Map map, File file, String kvSeparator, boolean isAppend) throws InternalException { return FileWriter.create(file, Charset.UTF_8).writeMap(map, kvSeparator, isAppend); } @@ -3388,9 +3387,9 @@ public static File writeMap(Map map, File file, String kvSeparator, boolea * @param kvSeparator 键和值之间的分隔符,如果传入null使用默认分隔符" = " * @param isAppend 是否追加 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeMap(Map map, File file, java.nio.charset.Charset charset, String kvSeparator, boolean isAppend) throws InstrumentException { + public static File writeMap(Map map, File file, java.nio.charset.Charset charset, String kvSeparator, boolean isAppend) throws InternalException { return FileWriter.create(file, charset).writeMap(map, kvSeparator, isAppend); } @@ -3400,9 +3399,9 @@ public static File writeMap(Map map, File file, java.nio.charset.Charset c * @param data 数据 * @param path 目标文件 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeBytes(byte[] data, String path) throws InstrumentException { + public static File writeBytes(byte[] data, String path) throws InternalException { return writeBytes(data, touch(path)); } @@ -3412,9 +3411,9 @@ public static File writeBytes(byte[] data, String path) throws InstrumentExcepti * @param dest 目标文件 * @param data 数据 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeBytes(byte[] data, File dest) throws InstrumentException { + public static File writeBytes(byte[] data, File dest) throws InternalException { return writeBytes(data, dest, 0, data.length, false); } @@ -3427,9 +3426,9 @@ public static File writeBytes(byte[] data, File dest) throws InstrumentException * @param len 数据长度 * @param isAppend 是否追加模式 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeBytes(byte[] data, File dest, int off, int len, boolean isAppend) throws InstrumentException { + public static File writeBytes(byte[] data, File dest, int off, int len, boolean isAppend) throws InternalException { return FileWriter.create(dest).write(data, off, len, isAppend); } @@ -3439,9 +3438,9 @@ public static File writeBytes(byte[] data, File dest, int off, int len, boolean * @param dest 目标文件 * @param in 输入流 * @return dest - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeFromStream(InputStream in, File dest) throws InstrumentException { + public static File writeFromStream(InputStream in, File dest) throws InternalException { return writeFromStream(in, dest, true); } @@ -3452,9 +3451,9 @@ public static File writeFromStream(InputStream in, File dest) throws InstrumentE * @param in 输入流 * @param isCloseIn 关闭输入流 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeFromStream(InputStream in, File dest, boolean isCloseIn) throws InstrumentException { + public static File writeFromStream(InputStream in, File dest, boolean isCloseIn) throws InternalException { return FileWriter.create(dest).writeFromStream(in, isCloseIn); } @@ -3464,9 +3463,9 @@ public static File writeFromStream(InputStream in, File dest, boolean isCloseIn) * @param in 输入流 * @param path 文件绝对路径 * @return 目标文件 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static File writeFromStream(InputStream in, String path) throws InstrumentException { + public static File writeFromStream(InputStream in, String path) throws InternalException { return writeFromStream(in, touch(path)); } @@ -3476,9 +3475,9 @@ public static File writeFromStream(InputStream in, String path) throws Instrumen * @param file 文件 * @param out 流 * @return 写出的流byte数 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static long writeToStream(File file, OutputStream out) throws InstrumentException { + public static long writeToStream(File file, OutputStream out) throws InternalException { return FileReader.create(file).writeToStream(out); } @@ -3488,9 +3487,9 @@ public static long writeToStream(File file, OutputStream out) throws InstrumentE * @param path 文件绝对路径 * @param out 输出流 * @return 写出的流byte数 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static long writeToStream(String path, OutputStream out) throws InstrumentException { + public static long writeToStream(String path, OutputStream out) throws InternalException { return writeToStream(touch(path), out); } @@ -3572,9 +3571,9 @@ public static boolean containsInvalid(String fileName) { * * @param file 文件,不能为目录 * @return CRC32值 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static long checksumCRC32(File file) throws InstrumentException { + public static long checksumCRC32(File file) throws InternalException { return checksum(file, new CRC32()).getValue(); } @@ -3584,9 +3583,9 @@ public static long checksumCRC32(File file) throws InstrumentException { * @param file 文件,不能为目录 * @param checksum {@link Checksum} * @return Checksum - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static Checksum checksum(File file, Checksum checksum) throws InstrumentException { + public static Checksum checksum(File file, Checksum checksum) throws InternalException { Assert.notNull(file, "File is null !"); if (file.isDirectory()) { throw new IllegalArgumentException("Checksums can't be computed on directories"); @@ -3594,7 +3593,7 @@ public static Checksum checksum(File file, Checksum checksum) throws InstrumentE try { return IoKit.checksum(new FileInputStream(file), checksum); } catch (FileNotFoundException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -3631,7 +3630,7 @@ public static String getParent(String filePath, int level) { try { return null == parent ? null : parent.getCanonicalPath(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -3658,7 +3657,7 @@ public static File getParent(File file, int level) { try { parentFile = file.getCanonicalFile().getParentFile(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (1 == level) { return parentFile; @@ -3734,7 +3733,7 @@ public static String getMediaType(Path file) { try { return Files.probeContentType(file); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -3917,7 +3916,7 @@ public static RandomAccessFile createRandomAccessFile(File file, FileMode mode) try { return new RandomAccessFile(file, mode.name()); } catch (FileNotFoundException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -3958,7 +3957,7 @@ public static BufferedReader getReaders(String resurce, java.nio.charset.Charset * * @param resurce ClassPath资源 * @return {@link InputStream} - * @throws InstrumentException 资源不存在异常 + * @throws InternalException 资源不存在异常 */ public static InputStream getStream(String resurce) { return new ClassPathResource(resurce).getStream(); @@ -3973,7 +3972,7 @@ public static InputStream getStream(String resurce) { public static InputStream getStreamSafe(String resurce) { try { return new ClassPathResource(resurce).getStream(); - } catch (InstrumentException e) { + } catch (InternalException e) { // ignore } return null; @@ -4024,7 +4023,7 @@ public static List getResources(String resource) { * @param filter 过滤器,用于过滤不需要的资源,{@code null}表示不过滤,保留所有元素 * @return 资源列表 */ - public static List getResources(String resource, Predicate filter) { + public static List getResources(String resource, Filter filter) { return IterKit.filterToList(getResourceIter(resource), filter); } @@ -4045,7 +4044,7 @@ public static EnumerationIterator getResourceIter(String resource) { try { resources = ClassKit.getClassLoader().getResources(resource); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return new EnumerationIterator<>(resources); } @@ -4162,9 +4161,9 @@ public static void addContent(File dir, String content) { fileWriter.write(text); fileWriter.close(); } catch (FileNotFoundException e) { - throw new InstrumentException("File NotFound !"); + throw new InternalException("File NotFound !"); } catch (IOException ex) { - throw new InstrumentException("I/O exception of some sort has occurred"); + throw new InternalException("I/O exception of some sort has occurred"); } } else { addContent(file, content); diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/GeoKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/GeoKit.java index 62be21d934..a2861d7c5e 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/GeoKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/GeoKit.java @@ -27,7 +27,7 @@ import org.aoju.bus.core.builder.EqualsBuilder; import org.aoju.bus.core.builder.HashCodeBuilder; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Normal; import java.awt.geom.Point2D; @@ -434,7 +434,7 @@ public Bounds() { */ public Bounds(Bounds first, Bounds other) { if (null == first || first.isEmpty() || null == other || other.isEmpty()) { - throw new InstrumentException("bounds"); + throw new InternalException("bounds"); } this.southWest = new Point(Math.min(first.southWest.getLongitude(), other.southWest.getLongitude()), Math.min(first.southWest.getLatitude(), other.southWest.getLatitude())); // diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/ImageKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/ImageKit.java index 3b7d862d6c..3a6f937553 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/ImageKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/ImageKit.java @@ -27,7 +27,7 @@ import org.aoju.bus.core.codec.Base64; import org.aoju.bus.core.convert.Convert; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.image.Images; import org.aoju.bus.core.image.Removal; import org.aoju.bus.core.io.resource.Resource; @@ -103,9 +103,9 @@ public static void scale(ImageInputStream srcStream, ImageOutputStream destStrea * @param srcImage 源图像来源流 * @param destFile 缩放后的图像写出到的流 * @param scale 缩放比例 比例大于1时为放大,小于1大于0为缩小 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void scale(java.awt.Image srcImage, File destFile, float scale) throws InstrumentException { + public static void scale(java.awt.Image srcImage, File destFile, float scale) throws InternalException { Images.from(srcImage).setTargetImageType(FileKit.getSuffix(destFile)).scale(scale).write(destFile); } @@ -116,9 +116,9 @@ public static void scale(java.awt.Image srcImage, File destFile, float scale) th * @param srcImage 源图像来源流 * @param out 缩放后的图像写出到的流 * @param scale 缩放比例 比例大于1时为放大,小于1大于0为缩小 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void scale(java.awt.Image srcImage, OutputStream out, float scale) throws InstrumentException { + public static void scale(java.awt.Image srcImage, OutputStream out, float scale) throws InternalException { scale(srcImage, getImageOutputStream(out), scale); } @@ -129,9 +129,9 @@ public static void scale(java.awt.Image srcImage, OutputStream out, float scale) * @param srcImage 源图像来源流 * @param destImageStream 缩放后的图像写出到的流 * @param scale 缩放比例 比例大于1时为放大,小于1大于0为缩小 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void scale(java.awt.Image srcImage, ImageOutputStream destImageStream, float scale) throws InstrumentException { + public static void scale(java.awt.Image srcImage, ImageOutputStream destImageStream, float scale) throws InternalException { writeJpg(scale(srcImage, scale), destImageStream); } @@ -168,9 +168,9 @@ public static java.awt.Image scale(java.awt.Image srcImage, int width, int heigh * @param width 缩放后的宽度 * @param height 缩放后的高度 * @param fixedColor 比例不对时补充的颜色,不补充为null - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void scale(File srcImageFile, File destImageFile, int width, int height, Color fixedColor) throws InstrumentException { + public static void scale(File srcImageFile, File destImageFile, int width, int height, Color fixedColor) throws InternalException { write(scale(read(srcImageFile), width, height, fixedColor), destImageFile); } @@ -183,9 +183,9 @@ public static void scale(File srcImageFile, File destImageFile, int width, int h * @param width 缩放后的宽度 * @param height 缩放后的高度 * @param fixedColor 比例不对时补充的颜色,不补充为null - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void scale(InputStream srcStream, OutputStream destStream, int width, int height, Color fixedColor) throws InstrumentException { + public static void scale(InputStream srcStream, OutputStream destStream, int width, int height, Color fixedColor) throws InternalException { scale(read(srcStream), getImageOutputStream(destStream), width, height, fixedColor); } @@ -198,9 +198,9 @@ public static void scale(InputStream srcStream, OutputStream destStream, int wid * @param width 缩放后的宽度 * @param height 缩放后的高度 * @param fixedColor 比例不对时补充的颜色,不补充为null - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void scale(ImageInputStream srcStream, ImageOutputStream destStream, int width, int height, Color fixedColor) throws InstrumentException { + public static void scale(ImageInputStream srcStream, ImageOutputStream destStream, int width, int height, Color fixedColor) throws InternalException { scale(read(srcStream), destStream, width, height, fixedColor); } @@ -213,9 +213,9 @@ public static void scale(ImageInputStream srcStream, ImageOutputStream destStrea * @param width 缩放后的宽度 * @param height 缩放后的高度 * @param fixedColor 比例不对时补充的颜色,不补充为null - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void scale(java.awt.Image srcImage, ImageOutputStream destImageStream, int width, int height, Color fixedColor) throws InstrumentException { + public static void scale(java.awt.Image srcImage, ImageOutputStream destImageStream, int width, int height, Color fixedColor) throws InternalException { writeJpg(scale(srcImage, width, height, fixedColor), destImageStream); } @@ -272,9 +272,9 @@ public static void cut(ImageInputStream srcStream, ImageOutputStream destStream, * @param srcImage 源图像 * @param destFile 输出的文件 * @param rectangle 矩形对象,表示矩形区域的x,y,width,height - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void cut(java.awt.Image srcImage, File destFile, Rectangle rectangle) throws InstrumentException { + public static void cut(java.awt.Image srcImage, File destFile, Rectangle rectangle) throws InternalException { write(cut(srcImage, rectangle), destFile); } @@ -284,9 +284,9 @@ public static void cut(java.awt.Image srcImage, File destFile, Rectangle rectang * @param srcImage 源图像 * @param out 切片后的图像输出流 * @param rectangle 矩形对象,表示矩形区域的x,y,width,height - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void cut(java.awt.Image srcImage, OutputStream out, Rectangle rectangle) throws InstrumentException { + public static void cut(java.awt.Image srcImage, OutputStream out, Rectangle rectangle) throws InternalException { cut(srcImage, getImageOutputStream(out), rectangle); } @@ -296,9 +296,9 @@ public static void cut(java.awt.Image srcImage, OutputStream out, Rectangle rect * @param srcImage 源图像 * @param destImageStream 切片后的图像输出流 * @param rectangle 矩形对象,表示矩形区域的x,y,width,height - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void cut(java.awt.Image srcImage, ImageOutputStream destImageStream, Rectangle rectangle) throws InstrumentException { + public static void cut(java.awt.Image srcImage, ImageOutputStream destImageStream, Rectangle rectangle) throws InternalException { writeJpg(cut(srcImage, rectangle), destImageStream); } @@ -413,7 +413,7 @@ public static void sliceByRowsAndCols(File srcImageFile, File destDir, int rows, try { sliceByRowsAndCols(ImageIO.read(srcImageFile), destDir, rows, cols); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -457,7 +457,7 @@ public static void sliceByRowsAndCols(java.awt.Image srcImage, File destDir, int } } } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -514,7 +514,7 @@ public static void convert(java.awt.Image srcImage, String formatName, ImageOutp try { ImageIO.write(isSrcPng ? copyImage(srcImage, BufferedImage.TYPE_INT_RGB) : toBufferedImage(srcImage), formatName, destImageStream); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -577,9 +577,9 @@ public static void gray(java.awt.Image srcImage, OutputStream out) { * * @param srcImage 源图像流 * @param destImageStream 目标图像流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void gray(java.awt.Image srcImage, ImageOutputStream destImageStream) throws InstrumentException { + public static void gray(java.awt.Image srcImage, ImageOutputStream destImageStream) throws InternalException { writeJpg(gray(srcImage), destImageStream); } @@ -656,9 +656,9 @@ public static void binary(java.awt.Image srcImage, OutputStream out, String imag * @param srcImage 源图像流 * @param destImageStream 目标图像流 * @param imageType 图片格式(扩展名) - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void binary(java.awt.Image srcImage, ImageOutputStream destImageStream, String imageType) throws InstrumentException { + public static void binary(java.awt.Image srcImage, ImageOutputStream destImageStream, String imageType) throws InternalException { write(binary(srcImage), imageType, destImageStream); } @@ -734,9 +734,9 @@ public static void pressText(ImageInputStream srcStream, ImageOutputStream destS * @param x 修正值 默认在中间,偏移量相对于中间偏移 * @param y 修正值 默认在中间,偏移量相对于中间偏移 * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void pressText(java.awt.Image srcImage, File destFile, String pressText, Color color, Font font, int x, int y, float alpha) throws InstrumentException { + public static void pressText(java.awt.Image srcImage, File destFile, String pressText, Color color, Font font, int x, int y, float alpha) throws InternalException { write(pressText(srcImage, pressText, color, font, x, y, alpha), destFile); } @@ -752,9 +752,9 @@ public static void pressText(java.awt.Image srcImage, File destFile, String pres * @param x 修正值 默认在中间,偏移量相对于中间偏移 * @param y 修正值 默认在中间,偏移量相对于中间偏移 * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void pressText(java.awt.Image srcImage, OutputStream to, String pressText, Color color, Font font, int x, int y, float alpha) throws InstrumentException { + public static void pressText(java.awt.Image srcImage, OutputStream to, String pressText, Color color, Font font, int x, int y, float alpha) throws InternalException { pressText(srcImage, getImageOutputStream(to), pressText, color, font, x, y, alpha); } @@ -770,9 +770,9 @@ public static void pressText(java.awt.Image srcImage, OutputStream to, String pr * @param x 修正值 默认在中间,偏移量相对于中间偏移 * @param y 修正值 默认在中间,偏移量相对于中间偏移 * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void pressText(java.awt.Image srcImage, ImageOutputStream destImageStream, String pressText, Color color, Font font, int x, int y, float alpha) throws InstrumentException { + public static void pressText(java.awt.Image srcImage, ImageOutputStream destImageStream, String pressText, Color color, Font font, int x, int y, float alpha) throws InternalException { writeJpg(pressText(srcImage, pressText, color, font, x, y, alpha), destImageStream); } @@ -832,9 +832,9 @@ public static void pressImage(InputStream srcStream, OutputStream destStream, ja * @param x 修正值 默认在中间,偏移量相对于中间偏移 * @param y 修正值 默认在中间,偏移量相对于中间偏移 * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void pressImage(ImageInputStream srcStream, ImageOutputStream destStream, java.awt.Image pressImage, int x, int y, float alpha) throws InstrumentException { + public static void pressImage(ImageInputStream srcStream, ImageOutputStream destStream, java.awt.Image pressImage, int x, int y, float alpha) throws InternalException { pressImage(read(srcStream), destStream, pressImage, x, y, alpha); } @@ -848,9 +848,9 @@ public static void pressImage(ImageInputStream srcStream, ImageOutputStream dest * @param x 修正值 默认在中间,偏移量相对于中间偏移 * @param y 修正值 默认在中间,偏移量相对于中间偏移 * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void pressImage(java.awt.Image srcImage, File outFile, java.awt.Image pressImage, int x, int y, float alpha) throws InstrumentException { + public static void pressImage(java.awt.Image srcImage, File outFile, java.awt.Image pressImage, int x, int y, float alpha) throws InternalException { write(pressImage(srcImage, pressImage, x, y, alpha), outFile); } @@ -864,9 +864,9 @@ public static void pressImage(java.awt.Image srcImage, File outFile, java.awt.Im * @param x 修正值 默认在中间,偏移量相对于中间偏移 * @param y 修正值 默认在中间,偏移量相对于中间偏移 * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void pressImage(java.awt.Image srcImage, OutputStream out, java.awt.Image pressImage, int x, int y, float alpha) throws InstrumentException { + public static void pressImage(java.awt.Image srcImage, OutputStream out, java.awt.Image pressImage, int x, int y, float alpha) throws InternalException { pressImage(srcImage, getImageOutputStream(out), pressImage, x, y, alpha); } @@ -880,9 +880,9 @@ public static void pressImage(java.awt.Image srcImage, OutputStream out, java.aw * @param x 修正值 默认在中间,偏移量相对于中间偏移 * @param y 修正值 默认在中间,偏移量相对于中间偏移 * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void pressImage(java.awt.Image srcImage, ImageOutputStream destImageStream, java.awt.Image pressImage, int x, int y, float alpha) throws InstrumentException { + public static void pressImage(java.awt.Image srcImage, ImageOutputStream destImageStream, java.awt.Image pressImage, int x, int y, float alpha) throws InternalException { writeJpg(pressImage(srcImage, pressImage, x, y, alpha), destImageStream); } @@ -922,9 +922,9 @@ public static java.awt.Image pressImage(java.awt.Image srcImage, java.awt.Image * @param imageFile 被旋转图像文件 * @param degree 旋转角度 * @param outFile 输出文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void rotate(File imageFile, int degree, File outFile) throws InstrumentException { + public static void rotate(File imageFile, int degree, File outFile) throws InternalException { rotate(read(imageFile), degree, outFile); } @@ -935,9 +935,9 @@ public static void rotate(File imageFile, int degree, File outFile) throws Instr * @param image 目标图像 * @param degree 旋转角度 * @param outFile 输出文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void rotate(java.awt.Image image, int degree, File outFile) throws InstrumentException { + public static void rotate(java.awt.Image image, int degree, File outFile) throws InternalException { write(rotate(image, degree), outFile); } @@ -948,9 +948,9 @@ public static void rotate(java.awt.Image image, int degree, File outFile) throws * @param image 目标图像 * @param degree 旋转角度 * @param out 输出流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void rotate(java.awt.Image image, int degree, OutputStream out) throws InstrumentException { + public static void rotate(java.awt.Image image, int degree, OutputStream out) throws InternalException { writeJpg(rotate(image, degree), getImageOutputStream(out)); } @@ -961,9 +961,9 @@ public static void rotate(java.awt.Image image, int degree, OutputStream out) th * @param image 目标图像 * @param degree 旋转角度 * @param out 输出图像流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void rotate(java.awt.Image image, int degree, ImageOutputStream out) throws InstrumentException { + public static void rotate(java.awt.Image image, int degree, ImageOutputStream out) throws InternalException { writeJpg(rotate(image, degree), out); } @@ -984,9 +984,9 @@ public static java.awt.Image rotate(java.awt.Image image, int degree) { * * @param imageFile 图像文件 * @param outFile 输出文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void flip(File imageFile, File outFile) throws InstrumentException { + public static void flip(File imageFile, File outFile) throws InternalException { flip(read(imageFile), outFile); } @@ -995,9 +995,9 @@ public static void flip(File imageFile, File outFile) throws InstrumentException * * @param image 图像 * @param outFile 输出文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void flip(java.awt.Image image, File outFile) throws InstrumentException { + public static void flip(java.awt.Image image, File outFile) throws InternalException { write(flip(image), outFile); } @@ -1006,9 +1006,9 @@ public static void flip(java.awt.Image image, File outFile) throws InstrumentExc * * @param image 图像 * @param out 输出 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void flip(java.awt.Image image, OutputStream out) throws InstrumentException { + public static void flip(java.awt.Image image, OutputStream out) throws InternalException { flip(image, getImageOutputStream(out)); } @@ -1017,9 +1017,9 @@ public static void flip(java.awt.Image image, OutputStream out) throws Instrumen * * @param image 图像 * @param out 输出 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void flip(java.awt.Image image, ImageOutputStream out) throws InstrumentException { + public static void flip(java.awt.Image image, ImageOutputStream out) throws InternalException { writeJpg(flip(image), out); } @@ -1039,9 +1039,9 @@ public static java.awt.Image flip(java.awt.Image image) { * @param imageFile 图像文件 * @param outFile 输出文件,只支持jpg文件 * @param quality 质量 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void compress(File imageFile, File outFile, float quality) throws InstrumentException { + public static void compress(File imageFile, File outFile, float quality) throws InternalException { Images.from(imageFile).setQuality(quality).write(outFile); } @@ -1172,9 +1172,9 @@ public static BufferedImage copyImage(java.awt.Image image, int imageType, Color * * @param base64 图像的Base64表示 * @return {@link BufferedImage} - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static BufferedImage toImage(String base64) throws InstrumentException { + public static BufferedImage toImage(String base64) throws InternalException { return toImage(Base64.decode(base64)); } @@ -1183,9 +1183,9 @@ public static BufferedImage toImage(String base64) throws InstrumentException { * * @param imageBytes 图像bytes * @return {@link BufferedImage} - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static BufferedImage toImage(byte[] imageBytes) throws InstrumentException { + public static BufferedImage toImage(byte[] imageBytes) throws InternalException { return read(new ByteArrayInputStream(imageBytes)); } @@ -1303,9 +1303,9 @@ public static Rectangle2D getRectangle(String text, Font font) { * * @param image {@link java.awt.Image} * @param destImageStream 写出到的目标流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void writeJpg(java.awt.Image image, ImageOutputStream destImageStream) throws InstrumentException { + public static void writeJpg(java.awt.Image image, ImageOutputStream destImageStream) throws InternalException { write(image, FileType.TYPE_JPG, destImageStream); } @@ -1314,9 +1314,9 @@ public static void writeJpg(java.awt.Image image, ImageOutputStream destImageStr * * @param image {@link java.awt.Image} * @param destImageStream 写出到的目标流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void writePng(java.awt.Image image, ImageOutputStream destImageStream) throws InstrumentException { + public static void writePng(java.awt.Image image, ImageOutputStream destImageStream) throws InternalException { write(image, FileType.TYPE_PNG, destImageStream); } @@ -1325,9 +1325,9 @@ public static void writePng(java.awt.Image image, ImageOutputStream destImageStr * * @param image {@link java.awt.Image} * @param out 写出到的目标流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void writeJpg(java.awt.Image image, OutputStream out) throws InstrumentException { + public static void writeJpg(java.awt.Image image, OutputStream out) throws InternalException { write(image, FileType.TYPE_JPG, out); } @@ -1336,9 +1336,9 @@ public static void writeJpg(java.awt.Image image, OutputStream out) throws Instr * * @param image {@link java.awt.Image} * @param out 写出到的目标流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void writePng(java.awt.Image image, OutputStream out) throws InstrumentException { + public static void writePng(java.awt.Image image, OutputStream out) throws InternalException { write(image, FileType.TYPE_PNG, out); } @@ -1348,9 +1348,9 @@ public static void writePng(java.awt.Image image, OutputStream out) throws Instr * @param image {@link java.awt.Image} * @param imageType 图片类型(图片扩展名) * @param out 写出到的目标流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void write(java.awt.Image image, String imageType, OutputStream out) throws InstrumentException { + public static void write(java.awt.Image image, String imageType, OutputStream out) throws InternalException { write(image, imageType, getImageOutputStream(out)); } @@ -1361,9 +1361,9 @@ public static void write(java.awt.Image image, String imageType, OutputStream ou * @param imageType 图片类型(图片扩展名) * @param destImageStream 写出到的目标流 * @return 是否成功写出, 如果返回false表示未找到合适的Writer - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static boolean write(java.awt.Image image, String imageType, ImageOutputStream destImageStream) throws InstrumentException { + public static boolean write(java.awt.Image image, String imageType, ImageOutputStream destImageStream) throws InternalException { return write(image, imageType, destImageStream, 1); } @@ -1375,9 +1375,9 @@ public static boolean write(java.awt.Image image, String imageType, ImageOutputS * @param destImageStream 写出到的目标流 * @param quality 质量,数字为0~1(不包括0和1)表示质量压缩比,除此数字外设置表示不压缩 * @return 是否成功写出, 如果返回false表示未找到合适的Writer - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static boolean write(java.awt.Image image, String imageType, ImageOutputStream destImageStream, float quality) throws InstrumentException { + public static boolean write(java.awt.Image image, String imageType, ImageOutputStream destImageStream, float quality) throws InternalException { if (StringKit.isBlank(imageType)) { imageType = FileType.TYPE_JPG; } @@ -1392,9 +1392,9 @@ public static boolean write(java.awt.Image image, String imageType, ImageOutputS * * @param image {@link java.awt.Image} * @param targetFile 目标文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void write(java.awt.Image image, File targetFile) throws InstrumentException { + public static void write(java.awt.Image image, File targetFile) throws InternalException { FileKit.touch(targetFile); ImageOutputStream out = null; try { @@ -1441,7 +1441,7 @@ public static boolean write(java.awt.Image image, ImageWriter writer, ImageOutpu } output.flush(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { writer.dispose(); } @@ -1483,7 +1483,7 @@ public static BufferedImage read(File imageFile) { try { result = ImageIO.read(imageFile); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (null == result) { @@ -1514,7 +1514,7 @@ public static BufferedImage read(InputStream imageStream) { try { result = ImageIO.read(imageStream); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (null == result) { @@ -1535,7 +1535,7 @@ public static BufferedImage read(ImageInputStream imageStream) { try { result = ImageIO.read(imageStream); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (null == result) { @@ -1556,7 +1556,7 @@ public static BufferedImage read(URL imageUrl) { try { result = ImageIO.read(imageUrl); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (null == result) { @@ -1571,14 +1571,14 @@ public static BufferedImage read(URL imageUrl) { * * @param out {@link OutputStream} * @return {@link ImageOutputStream} - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static ImageOutputStream getImageOutputStream(OutputStream out) throws InstrumentException { + public static ImageOutputStream getImageOutputStream(OutputStream out) throws InternalException { ImageOutputStream result; try { result = ImageIO.createImageOutputStream(out); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (null == result) { @@ -1593,14 +1593,14 @@ public static ImageOutputStream getImageOutputStream(OutputStream out) throws In * * @param outFile {@link File} * @return {@link ImageOutputStream} - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static ImageOutputStream getImageOutputStream(File outFile) throws InstrumentException { + public static ImageOutputStream getImageOutputStream(File outFile) throws InternalException { ImageOutputStream result; try { result = ImageIO.createImageOutputStream(outFile); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (null == result) { @@ -1615,14 +1615,14 @@ public static ImageOutputStream getImageOutputStream(File outFile) throws Instru * * @param in {@link InputStream} * @return {@link ImageInputStream} - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static ImageInputStream getImageInputStream(InputStream in) throws InstrumentException { + public static ImageInputStream getImageInputStream(InputStream in) throws InternalException { ImageOutputStream result; try { result = ImageIO.createImageOutputStream(in); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (null == result) { diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/IoKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/IoKit.java index 04c9e5b0a7..b8fe5cb1b5 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/IoKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/IoKit.java @@ -27,7 +27,7 @@ import org.aoju.bus.core.collection.LineIterator; import org.aoju.bus.core.convert.Convert; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.LifeCycle; import org.aoju.bus.core.io.LineHandler; import org.aoju.bus.core.io.Progress; @@ -156,9 +156,9 @@ public static boolean arrayRangeEquals( * @param reader Reader * @param writer Writer * @return 拷贝的字节数 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static long copy(Reader reader, Writer writer) throws InstrumentException { + public static long copy(Reader reader, Writer writer) throws InternalException { return copy(reader, writer, DEFAULT_BUFFER_SIZE); } @@ -169,9 +169,9 @@ public static long copy(Reader reader, Writer writer) throws InstrumentException * @param writer Writer * @param bufferSize 缓存大小 * @return 传输的byte数 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static long copy(Reader reader, Writer writer, int bufferSize) throws InstrumentException { + public static long copy(Reader reader, Writer writer, int bufferSize) throws InternalException { return copy(reader, writer, bufferSize, null); } @@ -183,9 +183,9 @@ public static long copy(Reader reader, Writer writer, int bufferSize) throws Ins * @param bufferSize 缓存大小 * @param progress 进度处理器 * @return 传输的byte数 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static long copy(Reader reader, Writer writer, int bufferSize, Progress progress) throws InstrumentException { + public static long copy(Reader reader, Writer writer, int bufferSize, Progress progress) throws InternalException { return copy(reader, writer, bufferSize, -1, progress); } @@ -198,9 +198,9 @@ public static long copy(Reader reader, Writer writer, int bufferSize, Progress p * @param count 最大长度 * @param progress 进度处理器 * @return 传输的byte数 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static long copy(Reader reader, Writer writer, int bufferSize, long count, Progress progress) throws InstrumentException { + public static long copy(Reader reader, Writer writer, int bufferSize, long count, Progress progress) throws InternalException { return new ReaderWriterCopier(bufferSize, count, progress).copy(reader, writer); } @@ -210,9 +210,9 @@ public static long copy(Reader reader, Writer writer, int bufferSize, long count * @param in 输入流 * @param out 输出流 * @return 传输的byte数 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static long copy(InputStream in, OutputStream out) throws InstrumentException { + public static long copy(InputStream in, OutputStream out) throws InternalException { return copy(in, out, DEFAULT_BUFFER_SIZE); } @@ -223,9 +223,9 @@ public static long copy(InputStream in, OutputStream out) throws InstrumentExcep * @param out 输出流 * @param bufferSize 缓存大小 * @return 传输的byte数 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static long copy(InputStream in, OutputStream out, int bufferSize) throws InstrumentException { + public static long copy(InputStream in, OutputStream out, int bufferSize) throws InternalException { return copy(in, out, bufferSize, null); } @@ -237,9 +237,9 @@ public static long copy(InputStream in, OutputStream out, int bufferSize) throws * @param bufferSize 缓存大小 * @param progress 进度条 * @return 传输的byte数 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static long copy(InputStream in, OutputStream out, int bufferSize, Progress progress) throws InstrumentException { + public static long copy(InputStream in, OutputStream out, int bufferSize, Progress progress) throws InternalException { return copy(in, out, bufferSize, -1, progress); } @@ -252,9 +252,9 @@ public static long copy(InputStream in, OutputStream out, int bufferSize, Progre * @param count 总拷贝长度 * @param progress 进度条 * @return 传输的byte数 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static long copy(InputStream in, OutputStream out, int bufferSize, int count, Progress progress) throws InstrumentException { + public static long copy(InputStream in, OutputStream out, int bufferSize, int count, Progress progress) throws InternalException { return new StreamCopier(bufferSize, count, progress).copy(in, out); } @@ -264,16 +264,16 @@ public static long copy(InputStream in, OutputStream out, int bufferSize, int co * @param inChannel {@link FileChannel} * @param outChannel {@link FileChannel} * @return 拷贝的字节数 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static long copy(FileChannel inChannel, FileChannel outChannel) throws InstrumentException { + public static long copy(FileChannel inChannel, FileChannel outChannel) throws InternalException { Assert.notNull(inChannel, "In channel is null!"); Assert.notNull(outChannel, "Out channel is null!"); try { return copySafely(inChannel, outChannel); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -320,9 +320,9 @@ private static long copySafely(FileChannel inChannel, FileChannel outChannel) th * @param count 最大长度 * @param progress 进度条 * @return 传输的byte数 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static long copy(InputStream in, OutputStream out, int bufferSize, long count, Progress progress) throws InstrumentException { + public static long copy(InputStream in, OutputStream out, int bufferSize, long count, Progress progress) throws InternalException { return copy(Channels.newChannel(in), Channels.newChannel(out), bufferSize, count, progress); } @@ -332,9 +332,9 @@ public static long copy(InputStream in, OutputStream out, int bufferSize, long c * @param in {@link ReadableByteChannel} * @param out {@link WritableByteChannel} * @return 拷贝的字节数 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static long copy(ReadableByteChannel in, WritableByteChannel out) throws InstrumentException { + public static long copy(ReadableByteChannel in, WritableByteChannel out) throws InternalException { return copy(in, out, DEFAULT_BUFFER_SIZE); } @@ -345,9 +345,9 @@ public static long copy(ReadableByteChannel in, WritableByteChannel out) throws * @param out {@link WritableByteChannel} * @param bufferSize 缓冲大小,如果小于等于0,使用默认 * @return 拷贝的字节数 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static long copy(ReadableByteChannel in, WritableByteChannel out, int bufferSize) throws InstrumentException { + public static long copy(ReadableByteChannel in, WritableByteChannel out, int bufferSize) throws InternalException { return copy(in, out, bufferSize, null); } @@ -359,9 +359,9 @@ public static long copy(ReadableByteChannel in, WritableByteChannel out, int buf * @param bufferSize 缓冲大小,如果小于等于0,使用默认 * @param progress {@link Progress}进度处理器 * @return 拷贝的字节数 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static long copy(ReadableByteChannel in, WritableByteChannel out, int bufferSize, Progress progress) throws InstrumentException { + public static long copy(ReadableByteChannel in, WritableByteChannel out, int bufferSize, Progress progress) throws InternalException { return copy(in, out, bufferSize, -1, progress); } @@ -374,9 +374,9 @@ public static long copy(ReadableByteChannel in, WritableByteChannel out, int buf * @param count 读取总长度 * @param progress {@link Progress}进度处理器 * @return 拷贝的字节数 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static long copy(ReadableByteChannel in, WritableByteChannel out, int bufferSize, long count, Progress progress) throws InstrumentException { + public static long copy(ReadableByteChannel in, WritableByteChannel out, int bufferSize, long count, Progress progress) throws InternalException { return new ChannelCopier(bufferSize, count, progress).copy(in, out); } @@ -496,9 +496,9 @@ public static OutputStreamWriter getWriter(OutputStream out, java.nio.charset.Ch * @param in 输入流 * @param charsetName 字符集 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String read(InputStream in, String charsetName) throws InstrumentException { + public static String read(InputStream in, String charsetName) throws InternalException { FastByteOutputStream out = read(in); return StringKit.isBlank(charsetName) ? out.toString() : out.toString(charsetName); } @@ -509,9 +509,9 @@ public static String read(InputStream in, String charsetName) throws InstrumentE * @param in 输入流,读取完毕后并不关闭流 * @param charset 字符集 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String read(InputStream in, java.nio.charset.Charset charset) throws InstrumentException { + public static String read(InputStream in, java.nio.charset.Charset charset) throws InternalException { FastByteOutputStream out = read(in); return null == charset ? out.toString() : out.toString(charset); } @@ -521,9 +521,9 @@ public static String read(InputStream in, java.nio.charset.Charset charset) thro * * @param in 输入流 * @return 输出流 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static FastByteOutputStream read(InputStream in) throws InstrumentException { + public static FastByteOutputStream read(InputStream in) throws InternalException { return read(in, true); } @@ -533,16 +533,16 @@ public static FastByteOutputStream read(InputStream in) throws InstrumentExcepti * @param in 输入流 * @param isClose 读取完毕后是否关闭流 * @return 输出流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static FastByteOutputStream read(InputStream in, boolean isClose) throws InstrumentException { + public static FastByteOutputStream read(InputStream in, boolean isClose) throws InternalException { final FastByteOutputStream out; if (in instanceof FileInputStream) { // 文件流的长度是可预见的,此时直接读取效率更高 try { out = new FastByteOutputStream(in.available()); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } else { out = new FastByteOutputStream(); @@ -562,9 +562,9 @@ public static FastByteOutputStream read(InputStream in, boolean isClose) throws * * @param reader Reader * @return String - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String read(Reader reader) throws InstrumentException { + public static String read(Reader reader) throws InternalException { return read(reader, true); } @@ -574,9 +574,9 @@ public static String read(Reader reader) throws InstrumentException { * @param reader {@link Reader} * @param isClose 是否关闭{@link Reader} * @return String - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static String read(Reader reader, boolean isClose) throws InstrumentException { + public static String read(Reader reader, boolean isClose) throws InternalException { final StringBuilder builder = StringKit.builder(); final CharBuffer buffer = CharBuffer.allocate(DEFAULT_BUFFER_SIZE); try { @@ -584,7 +584,7 @@ public static String read(Reader reader, boolean isClose) throws InstrumentExcep builder.append(buffer.flip()); } } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { if (isClose) { IoKit.close(reader); @@ -598,9 +598,9 @@ public static String read(Reader reader, boolean isClose) throws InstrumentExcep * * @param fileChannel 文件管道 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String read(FileChannel fileChannel) throws InstrumentException { + public static String read(FileChannel fileChannel) throws InternalException { return read(fileChannel, Charset.UTF_8); } @@ -610,9 +610,9 @@ public static String read(FileChannel fileChannel) throws InstrumentException { * @param fileChannel 文件管道 * @param charsetName 字符集 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String read(FileChannel fileChannel, String charsetName) throws InstrumentException { + public static String read(FileChannel fileChannel, String charsetName) throws InternalException { return read(fileChannel, Charset.charset(charsetName)); } @@ -622,14 +622,14 @@ public static String read(FileChannel fileChannel, String charsetName) throws In * @param fileChannel 文件管道 * @param charset 字符集 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String read(FileChannel fileChannel, java.nio.charset.Charset charset) throws InstrumentException { + public static String read(FileChannel fileChannel, java.nio.charset.Charset charset) throws InternalException { MappedByteBuffer buffer; try { buffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fileChannel.size()).load(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return StringKit.toString(buffer, charset); } @@ -640,9 +640,9 @@ public static String read(FileChannel fileChannel, java.nio.charset.Charset char * @param channel 可读通道,读取完毕后并不关闭通道 * @param charset 字符集 * @return 内容 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static String read(ReadableByteChannel channel, java.nio.charset.Charset charset) throws InstrumentException { + public static String read(ReadableByteChannel channel, java.nio.charset.Charset charset) throws InternalException { FastByteOutputStream out = read(channel); return null == charset ? out.toString() : out.toString(charset); } @@ -652,9 +652,9 @@ public static String read(ReadableByteChannel channel, java.nio.charset.Charset * * @param channel 可读通道,读取完毕后并不关闭通道 * @return 输出流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static FastByteOutputStream read(ReadableByteChannel channel) throws InstrumentException { + public static FastByteOutputStream read(ReadableByteChannel channel) throws InternalException { final FastByteOutputStream out = new FastByteOutputStream(); copy(channel, Channels.newChannel(out)); return out; @@ -665,9 +665,9 @@ public static FastByteOutputStream read(ReadableByteChannel channel) throws Inst * * @param in {@link InputStream} * @return bytes - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static byte[] readBytes(InputStream in) throws InstrumentException { + public static byte[] readBytes(InputStream in) throws InternalException { return readBytes(in, true); } @@ -677,9 +677,9 @@ public static byte[] readBytes(InputStream in) throws InstrumentException { * @param in {@link InputStream} * @param isClose 是否关闭输入流 * @return bytes - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static byte[] readBytes(InputStream in, boolean isClose) throws InstrumentException { + public static byte[] readBytes(InputStream in, boolean isClose) throws InternalException { if (in instanceof FileInputStream) { // 文件流的长度是可预见的,此时直接读取效率更高 final byte[] result; @@ -691,7 +691,7 @@ public static byte[] readBytes(InputStream in, boolean isClose) throws Instrumen throw new IOException(StringKit.format("File length is [{}] but read [{}]!", available, readLength)); } } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { if (isClose) { close(in); @@ -710,9 +710,9 @@ public static byte[] readBytes(InputStream in, boolean isClose) throws Instrumen * @param in {@link InputStream},为null返回null * @param length 长度,小于等于0返回空byte数组 * @return bytes - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static byte[] readBytes(InputStream in, int length) throws InstrumentException { + public static byte[] readBytes(InputStream in, int length) throws InternalException { if (null == in) { return null; } @@ -732,9 +732,9 @@ public static byte[] readBytes(InputStream in, int length) throws InstrumentExce * @param length 长度 * @param toLowerCase true 传换成小写格式 , false 传换成大写格式 * @return 16进制字符串 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String readHex(InputStream in, int length, boolean toLowerCase) throws InstrumentException { + public static String readHex(InputStream in, int length, boolean toLowerCase) throws InternalException { return HexKit.encodeHexString(readBytes(in, length), toLowerCase); } @@ -743,9 +743,9 @@ public static String readHex(InputStream in, int length, boolean toLowerCase) th * * @param in {@link InputStream} * @return 16进制字符串 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String readHex28Upper(InputStream in) throws InstrumentException { + public static String readHex28Upper(InputStream in) throws InternalException { return readHex(in, 28, false); } @@ -754,9 +754,9 @@ public static String readHex28Upper(InputStream in) throws InstrumentException { * * @param in {@link InputStream} * @return 16进制字符串 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static String readHex28Lower(InputStream in) throws InstrumentException { + public static String readHex28Lower(InputStream in) throws InternalException { return readHex(in, 28, true); } @@ -766,9 +766,9 @@ public static String readHex28Lower(InputStream in) throws InstrumentException { * @param 读取对象的类型 * @param in 输入流 * @return 输出流 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static T readObject(InputStream in) throws InstrumentException { + public static T readObject(InputStream in) throws InternalException { if (null == in) { throw new IllegalArgumentException("The InputStream must not be null"); } @@ -778,9 +778,9 @@ public static T readObject(InputStream in) throws InstrumentException { final T object = (T) ois.readObject(); return object; } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } catch (ClassNotFoundException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -791,9 +791,9 @@ public static T readObject(InputStream in) throws InstrumentException { * @param in 输入流 * @param collection 返回集合 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static > T readUtf8Lines(InputStream in, T collection) throws InstrumentException { + public static > T readUtf8Lines(InputStream in, T collection) throws InternalException { return readLines(in, Charset.UTF_8, collection); } @@ -805,9 +805,9 @@ public static > T readUtf8Lines(InputStream in, T c * @param charsetName 字符集 * @param collection 返回集合 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static > T readLines(InputStream in, String charsetName, T collection) throws InstrumentException { + public static > T readLines(InputStream in, String charsetName, T collection) throws InternalException { return readLines(in, Charset.charset(charsetName), collection); } @@ -819,9 +819,9 @@ public static > T readLines(InputStream in, String * @param charset 字符集 * @param collection 返回集合 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static > T readLines(InputStream in, java.nio.charset.Charset charset, T collection) throws InstrumentException { + public static > T readLines(InputStream in, java.nio.charset.Charset charset, T collection) throws InternalException { return readLines(getReader(in, charset), collection); } @@ -832,9 +832,9 @@ public static > T readLines(InputStream in, java.ni * @param reader {@link Reader} * @param collection 返回集合 * @return 内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static > T readLines(Reader reader, T collection) throws InstrumentException { + public static > T readLines(Reader reader, T collection) throws InternalException { readLines(reader, (LineHandler) line -> collection.add(line)); return collection; } @@ -844,9 +844,9 @@ public static > T readLines(Reader reader, T collec * * @param in {@link InputStream} * @param lineHandler 行处理接口,实现handle方法用于编辑一行的数据后入到指定地方 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static void readUtf8Lines(InputStream in, LineHandler lineHandler) throws InstrumentException { + public static void readUtf8Lines(InputStream in, LineHandler lineHandler) throws InternalException { readLines(in, Charset.UTF_8, lineHandler); } @@ -856,9 +856,9 @@ public static void readUtf8Lines(InputStream in, LineHandler lineHandler) throws * @param in {@link InputStream} * @param charset {@link java.nio.charset.Charset}编码 * @param lineHandler 行处理接口,实现handle方法用于编辑一行的数据后入到指定地方 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static void readLines(InputStream in, java.nio.charset.Charset charset, LineHandler lineHandler) throws InstrumentException { + public static void readLines(InputStream in, java.nio.charset.Charset charset, LineHandler lineHandler) throws InternalException { readLines(getReader(in, charset), lineHandler); } @@ -868,9 +868,9 @@ public static void readLines(InputStream in, java.nio.charset.Charset charset, L * * @param reader {@link Reader} * @param lineHandler 行处理接口,实现handle方法用于编辑一行的数据后入到指定地方 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static void readLines(Reader reader, LineHandler lineHandler) throws InstrumentException { + public static void readLines(Reader reader, LineHandler lineHandler) throws InternalException { Assert.notNull(reader); Assert.notNull(lineHandler); @@ -924,7 +924,7 @@ public static FileInputStream toStream(File file) { try { return new FileInputStream(file); } catch (FileNotFoundException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1035,13 +1035,13 @@ public static PushbackInputStream toPushbackStream(InputStream in, int pushBackS * @param out 输出流 * @param isCloseOut 写入完毕是否关闭输出流 * @param content 写入的内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static void write(OutputStream out, boolean isCloseOut, byte[] content) throws InstrumentException { + public static void write(OutputStream out, boolean isCloseOut, byte[] content) throws InternalException { try { out.write(content); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { if (isCloseOut) { close(out); @@ -1055,9 +1055,9 @@ public static void write(OutputStream out, boolean isCloseOut, byte[] content) t * @param out 输出流 * @param isCloseOut 写入完毕是否关闭输出流 * @param contents 写入的内容,调用toString()方法,不包括不会自动换行 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static void writeUtf8(OutputStream out, boolean isCloseOut, Object... contents) throws InstrumentException { + public static void writeUtf8(OutputStream out, boolean isCloseOut, Object... contents) throws InternalException { write(out, Charset.UTF_8, isCloseOut, contents); } @@ -1068,9 +1068,9 @@ public static void writeUtf8(OutputStream out, boolean isCloseOut, Object... con * @param charsetName 写出的内容的字符集 * @param isCloseOut 写入完毕是否关闭输出流 * @param contents 写入的内容,调用toString()方法,不包括不会自动换行 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static void write(OutputStream out, String charsetName, boolean isCloseOut, Object... contents) throws InstrumentException { + public static void write(OutputStream out, String charsetName, boolean isCloseOut, Object... contents) throws InternalException { write(out, Charset.charset(charsetName), isCloseOut, contents); } @@ -1081,9 +1081,9 @@ public static void write(OutputStream out, String charsetName, boolean isCloseOu * @param charset 写出的内容的字符集 * @param isCloseOut 写入完毕是否关闭输出流 * @param contents 写入的内容,调用toString()方法,不包括不会自动换行 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static void write(OutputStream out, java.nio.charset.Charset charset, boolean isCloseOut, Object... contents) throws InstrumentException { + public static void write(OutputStream out, java.nio.charset.Charset charset, boolean isCloseOut, Object... contents) throws InternalException { OutputStreamWriter osw = null; try { osw = getWriter(out, charset); @@ -1094,7 +1094,7 @@ public static void write(OutputStream out, java.nio.charset.Charset charset, boo } osw.flush(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { if (isCloseOut) { close(osw); @@ -1109,7 +1109,7 @@ public static void write(OutputStream out, java.nio.charset.Charset charset, boo * @param isCloseOut 写入完毕是否关闭输出流 * @param object 写入的对象内容 */ - public static void write(OutputStream out, boolean isCloseOut, Serializable object) throws InstrumentException { + public static void write(OutputStream out, boolean isCloseOut, Serializable object) throws InternalException { writeObjects(out, isCloseOut, object); } @@ -1119,9 +1119,9 @@ public static void write(OutputStream out, boolean isCloseOut, Serializable obje * @param out 输出流 * @param isCloseOut 写入完毕是否关闭输出流 * @param contents 写入的内容 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static void writeObjects(OutputStream out, boolean isCloseOut, Serializable... contents) throws InstrumentException { + public static void writeObjects(OutputStream out, boolean isCloseOut, Serializable... contents) throws InternalException { ObjectOutputStream osw = null; try { osw = out instanceof ObjectOutputStream ? (ObjectOutputStream) out : new ObjectOutputStream(out); @@ -1132,7 +1132,7 @@ public static void writeObjects(OutputStream out, boolean isCloseOut, Serializab } osw.flush(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { if (isCloseOut) { close(osw); @@ -1253,9 +1253,9 @@ public static void flush(Flushable flushable) { * @param input1 第一个流 * @param input2 第二个流 * @return 两个流的内容一致返回true, 否则false - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static boolean contentEquals(InputStream input1, InputStream input2) throws InstrumentException { + public static boolean contentEquals(InputStream input1, InputStream input2) throws InternalException { if (false == (input1 instanceof BufferedInputStream)) { input1 = new BufferedInputStream(input1); } @@ -1276,7 +1276,7 @@ public static boolean contentEquals(InputStream input1, InputStream input2) thro int ch2 = input2.read(); return ch2 == EOF; } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1287,9 +1287,9 @@ public static boolean contentEquals(InputStream input1, InputStream input2) thro * @param input1 第一个reader * @param input2 第二个reader * @return 两个流的内容一致返回true, 否则false - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static boolean contentEquals(Reader input1, Reader input2) throws InstrumentException { + public static boolean contentEquals(Reader input1, Reader input2) throws InternalException { input1 = getReader(input1); input2 = getReader(input2); @@ -1306,7 +1306,7 @@ public static boolean contentEquals(Reader input1, Reader input2) throws Instrum int ch2 = input2.read(); return ch2 == EOF; } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1317,9 +1317,9 @@ public static boolean contentEquals(Reader input1, Reader input2) throws Instrum * @param input1 第一个流 * @param input2 第二个流 * @return 两个流的内容一致返回true, 否则false - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static boolean contentEqualsIgnoreEOL(Reader input1, Reader input2) throws InstrumentException { + public static boolean contentEqualsIgnoreEOL(Reader input1, Reader input2) throws InternalException { final BufferedReader br1 = getReader(input1); final BufferedReader br2 = getReader(input2); @@ -1332,7 +1332,7 @@ public static boolean contentEqualsIgnoreEOL(Reader input1, Reader input2) throw } return null == line1 ? null == line2 : line1.equals(line2); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1341,9 +1341,9 @@ public static boolean contentEqualsIgnoreEOL(Reader input1, Reader input2) throw * * @param in 文件,不能为目录 * @return CRC32值 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static long checksumCRC32(InputStream in) throws InstrumentException { + public static long checksumCRC32(InputStream in) throws InternalException { return checksum(in, new CRC32()).getValue(); } @@ -1353,9 +1353,9 @@ public static long checksumCRC32(InputStream in) throws InstrumentException { * @param in 流 * @param checksum {@link Checksum} * @return Checksum - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static Checksum checksum(InputStream in, Checksum checksum) throws InstrumentException { + public static Checksum checksum(InputStream in, Checksum checksum) throws InternalException { Assert.notNull(in, "InputStream is null !"); if (null == checksum) { checksum = new CRC32(); @@ -1679,10 +1679,10 @@ protected void timedOut() { try { socket.close(); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } catch (AssertionError e) { if (isAndroidGetsocknameError(e)) { - throw new InstrumentException(e); + throw new InternalException(e); } else { throw e; } diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/IterKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/IterKit.java index d297f69ea4..3fa9d27f9b 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/IterKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/IterKit.java @@ -29,7 +29,7 @@ import org.aoju.bus.core.collection.EnumerationIterator; import org.aoju.bus.core.collection.FilterIterator; import org.aoju.bus.core.collection.NodeListIterator; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Filter; import org.aoju.bus.core.lang.Matcher; @@ -41,7 +41,6 @@ import java.util.*; import java.util.function.Consumer; import java.util.function.Function; -import java.util.function.Predicate; /** * {@link Iterable} 和 {@link Iterator} 相关工具类 @@ -646,8 +645,9 @@ public static Iterable asIterable(final Iterator iter) { * @return 第一个元素 */ public static T getFirst(Iterable iterable) { - if (null == iterable) { - return null; + if (iterable instanceof List) { + final List list = (List) iterable; + return CollKit.isEmpty(list) ? null : list.get(0); } return getFirst(iterable.iterator()); } @@ -795,7 +795,7 @@ public static Iterator filter(Iterator iterator, Filter filter) { * @param filter 过滤器,保留{@link Filter#accept(Object)}为{@code true}的元素 * @return the list */ - public static List filterToList(Iterator iter, Predicate filter) { + public static List filterToList(Iterator iter, Filter filter) { return toList(filtered(iter, filter)); } @@ -807,7 +807,7 @@ public static List filterToList(Iterator iter, Predicate filter) { * @param 元素类型 * @return {@link FilterIterator} */ - public static FilterIterator filtered(final Iterator iterator, final Predicate filter) { + public static FilterIterator filtered(final Iterator iterator, final Filter filter) { return new FilterIterator<>(iterator, filter); } @@ -854,7 +854,7 @@ public static Map toMap(Iterator iterator, Map map, Fun try { map.put(keyFunc.call(element), valueFunc.call(element)); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } return map; diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/MapKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/MapKit.java index ccdb18402a..f262bcbbac 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/MapKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/MapKit.java @@ -26,7 +26,7 @@ package org.aoju.bus.core.toolkit; import org.aoju.bus.core.convert.Convert; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Editor; import org.aoju.bus.core.lang.Filter; import org.aoju.bus.core.lang.Normal; @@ -219,7 +219,7 @@ public static Map createMap(Class mapType) { } else { try { return (Map) ReflectKit.newInstance(mapType); - } catch (InstrumentException e) { + } catch (InternalException e) { // 不支持的map类型,返回默认的HashMap return new HashMap<>(); } diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/MathKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/MathKit.java index 89acab3645..de5084fb68 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/MathKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/MathKit.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.toolkit; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Normal; import org.aoju.bus.core.lang.Symbol; @@ -727,7 +727,7 @@ public static BigDecimal round(double v, int scale) { * @return 新值 */ public static String roundString(double v, int scale) { - return round(v, scale).toString(); + return round(v, scale).toPlainString(); } /** @@ -735,12 +735,12 @@ public static String roundString(double v, int scale) { * 采用四舍五入策略 {@link RoundingMode#HALF_UP} * 例如保留2位小数:123.456789 = 123.46 * - * @param numberStr 数字值的字符串表现形式 - * @param scale 保留小数位数 + * @param number 数字值的字符串表现形式 + * @param scale 保留小数位数 * @return 新值 */ - public static BigDecimal round(String numberStr, int scale) { - return round(numberStr, scale, RoundingMode.HALF_UP); + public static BigDecimal round(String number, int scale) { + return round(number, scale, RoundingMode.HALF_UP); } /** @@ -761,12 +761,12 @@ public static BigDecimal round(BigDecimal number, int scale) { * 采用四舍五入策略 {@link RoundingMode#HALF_UP} * 例如保留2位小数:123.456789 = 123.46 * - * @param numberStr 数字值的字符串表现形式 + * @param number 数字值的字符串表现形式 * @param scale 保留小数位数 * @return 新值 */ - public static String roundString(String numberStr, int scale) { - return round(numberStr, scale).toString(); + public static String roundString(String number, int scale) { + return round(number, scale).toPlainString(); } /** @@ -792,24 +792,24 @@ public static BigDecimal round(double v, int scale, RoundingMode roundingMode) { * @return 新值 */ public static String roundString(double v, int scale, RoundingMode roundingMode) { - return round(v, scale, roundingMode).toString(); + return round(v, scale, roundingMode).toPlainString(); } /** * 保留固定位数小数 * 例如保留四位小数:123.456789 = 123.4567 * - * @param numberStr 数字值的字符串表现形式 + * @param number 数字值的字符串表现形式 * @param scale 保留小数位数,如果传入小于0,则默认0 * @param roundingMode 保留小数的模式 {@link RoundingMode},如果传入null则默认四舍五入 * @return 新值 */ - public static BigDecimal round(String numberStr, int scale, RoundingMode roundingMode) { - Assert.notBlank(numberStr); + public static BigDecimal round(String number, int scale, RoundingMode roundingMode) { + Assert.notBlank(number); if (scale < 0) { scale = 0; } - return round(toBigDecimal(numberStr), scale, roundingMode); + return round(toBigDecimal(number), scale, roundingMode); } /** @@ -839,13 +839,13 @@ public static BigDecimal round(BigDecimal number, int scale, RoundingMode roundi * 保留固定位数小数 * 例如保留四位小数:123.456789 = 123.4567 * - * @param numberStr 数字值的字符串表现形式 + * @param number 数字值的字符串表现形式 * @param scale 保留小数位数 * @param roundingMode 保留小数的模式 {@link RoundingMode} * @return 新值 */ - public static String roundString(String numberStr, int scale, RoundingMode roundingMode) { - return round(numberStr, scale, roundingMode).toString(); + public static String roundString(String number, int scale, RoundingMode roundingMode) { + return round(number, scale, roundingMode).toPlainString(); } /** @@ -1278,7 +1278,7 @@ public static Integer[] generateBySet(int begin, int end, int size) { } // 加入逻辑判断,确保begin set = new HashSet<>(size, 1); @@ -2249,6 +2249,11 @@ public static int parseInt(String number) throws NumberFormatException { return 0; } + if (StringKit.containsIgnoreCase(number, "E")) { + // 科学计数法忽略支持,科学计数法一般用于表示非常小和非常大的数字,这类数字转换为int后精度丢失,没有意义 + throw new NumberFormatException(StringKit.format("Unsupported int format: [{}]", number)); + } + if (StringKit.startWithIgnoreCase(number, "0x")) { // 0x04表示16进制数 return Integer.parseInt(number.substring(2), Normal._16); @@ -2345,14 +2350,14 @@ public static double parseDouble(String number) { * 将指定字符串转换为{@link Number} 对象 * 此方法不支持科学计数法 * - * @param numberStr Number字符串 + * @param number Number字符串 * @return Number对象 * @throws NumberFormatException 包装了{@link ParseException},当给定的数字字符串无法解析时抛出 */ - public static Number parseNumber(String numberStr) throws NumberFormatException { - if (StringKit.startWithIgnoreCase(numberStr, "0x")) { + public static Number parseNumber(String number) throws NumberFormatException { + if (StringKit.startWithIgnoreCase(number, "0x")) { // 0x04表示16进制数 - return Long.parseLong(numberStr.substring(2), 16); + return Long.parseLong(number.substring(2), 16); } try { @@ -2361,7 +2366,7 @@ public static Number parseNumber(String numberStr) throws NumberFormatException // 当字符串数字超出double的长度时,会导致截断,此处使用BigDecimal接收 ((DecimalFormat) format).setParseBigDecimal(true); } - return format.parse(numberStr); + return format.parse(number); } catch (ParseException e) { final NumberFormatException nfe = new NumberFormatException(e.getMessage()); nfe.initCause(e); diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/NetKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/NetKit.java index e6697d1980..168949fd9c 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/NetKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/NetKit.java @@ -27,7 +27,7 @@ import org.aoju.bus.core.collection.EnumerationIterator; import org.aoju.bus.core.convert.Convert; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.*; import javax.naming.InitialContext; @@ -202,7 +202,7 @@ public static int getUsableLocalPort(int minPort, int maxPort) { } } - throw new InstrumentException("Could not find an available port in the range [{}, {}] after {} attempts", minPort, maxPort, maxPort - minPort); + throw new InternalException("Could not find an available port in the range [{}, {}] after {} attempts", minPort, maxPort, maxPort - minPort); } /** @@ -231,7 +231,7 @@ public static byte[] getHardwareAddress(InetAddress inetAddress) { return networkInterface.getHardwareAddress(); } } catch (SocketException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return null; } @@ -253,7 +253,7 @@ public static TreeSet getUsableLocalPorts(int numRequested, int minPort } if (availablePorts.size() != numRequested) { - throw new InstrumentException("Could not find {} available ports in the range [{}, {}]", numRequested, minPort, maxPort); + throw new InternalException("Could not find {} available ports in the range [{}, {}]", numRequested, minPort, maxPort); } return availablePorts; } @@ -294,7 +294,7 @@ public static String toAbsoluteUrl(String absoluteBasePath, String relativePath) URL absoluteUrl = new URL(absoluteBasePath); return new URL(absoluteUrl, relativePath).toString(); } catch (Exception e) { - throw new InstrumentException("To absolute url [{}] base [{}] error!", relativePath, absoluteBasePath); + throw new InternalException("To absolute url [{}] base [{}] error!", relativePath, absoluteBasePath); } } @@ -466,11 +466,11 @@ public static LinkedHashSet localAddressList(Filter ad try { networkInterfaces = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (null == networkInterfaces) { - throw new InstrumentException("Get network interface error!"); + throw new InternalException("Get network interface error!"); } final LinkedHashSet ipSet = new LinkedHashSet<>(); @@ -608,7 +608,7 @@ public static String getMacAddress(InetAddress inetAddress, String separator) { mac = networkInterface.getHardwareAddress(); } } catch (SocketException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (null != mac) { final StringBuilder sb = new StringBuilder(); @@ -647,14 +647,14 @@ public static InetSocketAddress createAddress(String host, int port) { * @param port Server端口 * @param isBlock 是否阻塞方式 * @param data 需要发送的数据 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void netCat(String host, int port, boolean isBlock, ByteBuffer data) throws InstrumentException { + public static void netCat(String host, int port, boolean isBlock, ByteBuffer data) throws InternalException { try (SocketChannel channel = SocketChannel.open(createAddress(host, port))) { channel.configureBlocking(isBlock); channel.write(data); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -664,16 +664,16 @@ public static void netCat(String host, int port, boolean isBlock, ByteBuffer dat * @param host Server主机 * @param port Server端口 * @param data 数据 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - public static void netCat(String host, int port, byte[] data) throws InstrumentException { + public static void netCat(String host, int port, byte[] data) throws InternalException { OutputStream out = null; try (Socket socket = new Socket(host, port)) { out = socket.getOutputStream(); out.write(data); out.flush(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(out); } @@ -832,7 +832,7 @@ public static InitialDirContext createInitialDirContext(Map envi } return new InitialDirContext(Convert.convert(Hashtable.class, environment)); } catch (NamingException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -849,7 +849,7 @@ public static InitialContext createInitialContext(Map environmen } return new InitialContext(Convert.convert(Hashtable.class, environment)); } catch (NamingException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -865,7 +865,7 @@ public static Attributes getAttributes(String uri, String... attrIds) { try { return createInitialDirContext(null).getAttributes(uri, attrIds); } catch (NamingException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/ObjectKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/ObjectKit.java index 338d61f5e6..7bfbd1bbf3 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/ObjectKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/ObjectKit.java @@ -28,7 +28,7 @@ import org.aoju.bus.core.compare.NormalCompare; import org.aoju.bus.core.compare.PinyinCompare; import org.aoju.bus.core.convert.Convert; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.stream.FastByteOutputStream; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Normal; @@ -511,10 +511,10 @@ public static String toString(Object object) { * 序列化后拷贝流的方式克隆 * 对象必须实现Serializable接口 * - * @param 对象类型 + * @param 对象类型 * @param object 被克隆对象 * @return 克隆后的对象 - * @throws InstrumentException IO异常和ClassNotFoundException封装 + * @throws InternalException IO异常和ClassNotFoundException封装 */ public static T cloneByStream(T object) { if (null == object || false == (object instanceof Serializable)) { @@ -529,7 +529,7 @@ public static T cloneByStream(T object) { final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(byteOut.toByteArray())); return (T) in.readObject(); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -742,7 +742,7 @@ public static byte[] toByte(Object object) { objOut.writeObject(object); return byteOut.toByteArray(); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -770,7 +770,7 @@ public static T toObject(byte[] bts) { ObjectInputStream objIn = new ObjectInputStream(byteIn); return (T) objIn.readObject(); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -783,7 +783,7 @@ public static Class getClassByName(String classAllName) { try { return Class.forName(classAllName); } catch (ClassNotFoundException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -817,7 +817,7 @@ public static T initObject(Class clazz, Map attrMap) { } return object; } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -843,7 +843,7 @@ public static void setAttribute(Object object, String attrName, Object value) { } } } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -872,7 +872,7 @@ public static Object getAttributeValue(Object object, String attrName) { return null; } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -901,7 +901,7 @@ public static Map getFields(Object bean) { map.remove("serialVersionUID"); return map; } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -923,7 +923,7 @@ public static Map getFieldNames(Class clazz) { attrMap.remove("serialVersionUID"); return attrMap; } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -958,7 +958,7 @@ public static Map getNotNullFields(Object bean, boolean hasInitV map.remove("serialVersionUID"); return map; } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1020,7 +1020,7 @@ public static Map> getNotNullFieldsParam(Object bean, boole map.remove("serialVersionUID"); return map; } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1056,7 +1056,7 @@ public static Map getNotNullFieldsForStructure(Object bean) { map.remove("serialVersionUID"); return map; } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1075,7 +1075,7 @@ public static Class getGeneric(Class clazz) { Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); return (Class) params[0]; } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1093,7 +1093,7 @@ public static T parseByteForObject(byte[] bts) { objectInput = new ObjectInputStream(input); return (T) objectInput.readObject(); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { try { if (null != objectInput) { @@ -1103,7 +1103,7 @@ public static T parseByteForObject(byte[] bts) { input.close(); } } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } } @@ -1122,7 +1122,7 @@ public static byte[] parseObjForByte(Object object) { objOut.writeObject(object); return byteOut.toByteArray(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { try { if (null != objOut) { @@ -1132,7 +1132,7 @@ public static byte[] parseObjForByte(Object object) { byteOut.close(); } } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } } @@ -1230,7 +1230,7 @@ public static T CloneObject(Class clazz, Object bean) { Map attrMap = getFields(bean); return initObject(clazz, attrMap); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1245,7 +1245,7 @@ public static T CloneObject(T bean) { Map attrMap = getFields(bean); return (T) initObject(bean.getClass(), attrMap); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1271,7 +1271,7 @@ public static void insertObject(Object baseData, Object newData) { } } } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1304,7 +1304,7 @@ public static void cleanInitValue(T bean) { } } } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/PatternKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/PatternKit.java index 0508baf1ca..95ca93ff17 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/PatternKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/PatternKit.java @@ -26,7 +26,7 @@ package org.aoju.bus.core.toolkit; import org.aoju.bus.core.convert.Convert; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Normal; import org.aoju.bus.core.lang.RegEx; @@ -319,7 +319,7 @@ public static Map getAllGroupNames(String regex, CharSequence co } return result; } catch (InvocationTargetException | IllegalAccessException ex) { - throw new InstrumentException("call getAllGroupNames(...) method error: " + ex.getMessage()); + throw new InternalException("call getAllGroupNames(...) method error: " + ex.getMessage()); } } @@ -843,7 +843,7 @@ public static String replaceAll(CharSequence text, Pattern pattern, Func1 fieldType = field.getType(); @@ -623,7 +623,7 @@ public static void setFieldValue(Object object, Field field, Object value) throw try { field.set(object instanceof Class ? null : object, value); } catch (IllegalAccessException e) { - throw new InstrumentException("IllegalAccess for {}.{}", object, field.getName()); + throw new InternalException("IllegalAccess for {}.{}", object, field.getName()); } } @@ -901,13 +901,13 @@ public static boolean isGetterOrSetter(Method method, boolean ignoreCase) { * @param 对象类型 * @param clazz 类名 * @return 对象 - * @throws InstrumentException 包装各类异常 + * @throws InternalException 包装各类异常 */ - public static T newInstance(String clazz) throws InstrumentException { + public static T newInstance(String clazz) throws InternalException { try { return (T) Class.forName(clazz).newInstance(); } catch (Exception e) { - throw new InstrumentException(StringKit.format("Instance class [{}] error!", clazz), e); + throw new InternalException(StringKit.format("Instance class [{}] error!", clazz), e); } } @@ -918,30 +918,30 @@ public static T newInstance(String clazz) throws InstrumentException { * @param clazz 类 * @param params 构造函数参数 * @return 对象 - * @throws InstrumentException 包装各类异常 + * @throws InternalException 包装各类异常 */ - public static T newInstance(Class clazz, Object... params) throws InstrumentException { + public static T newInstance(Class clazz, Object... params) throws InternalException { if (ArrayKit.isEmpty(params)) { final Constructor constructor = getConstructor(clazz); if (null == constructor) { - throw new InstrumentException("No constructor for [{}]", clazz); + throw new InternalException("No constructor for [{}]", clazz); } try { return constructor.newInstance(); } catch (Exception e) { - throw new InstrumentException(e, "Instance class [{}] error!", clazz); + throw new InternalException(e, "Instance class [{}] error!", clazz); } } final Class[] paramTypes = ClassKit.getClasses(params); final Constructor constructor = getConstructor(clazz, paramTypes); if (null == constructor) { - throw new InstrumentException("No Constructor matched for parameter types: [{}]", new Object[]{paramTypes}); + throw new InternalException("No Constructor matched for parameter types: [{}]", new Object[]{paramTypes}); } try { return constructor.newInstance(params); } catch (Exception e) { - throw new InstrumentException(e, "Instance class [{}] error!", clazz); + throw new InternalException(e, "Instance class [{}] error!", clazz); } } @@ -1009,9 +1009,9 @@ public static T newInstanceIfPossible(Class type) { * @param method 方法(对象方法或static方法都可) * @param args 参数对象 * @return 结果 - * @throws InstrumentException 多种异常包装 + * @throws InternalException 多种异常包装 */ - public static T invokeStatic(Method method, Object... args) throws InstrumentException { + public static T invokeStatic(Method method, Object... args) throws InternalException { return invoke(null, method, args); } @@ -1029,9 +1029,9 @@ public static T invokeStatic(Method method, Object... args) throws Instrumen * @param method 方法(对象方法或static方法都可) * @param args 参数对象 * @return 结果 - * @throws InstrumentException 一些列异常的包装 + * @throws InternalException 一些列异常的包装 */ - public static T invokeWithCheck(Object object, Method method, Object... args) throws InstrumentException { + public static T invokeWithCheck(Object object, Method method, Object... args) throws InternalException { final Class[] types = method.getParameterTypes(); if (null != types && null != args) { Assert.isTrue(args.length == types.length, "Params length [{}] is not fit for param length [{}] of method !", args.length, types.length); @@ -1086,7 +1086,7 @@ public static T invoke(Object object, Method method, Object... args) { try { return (T) method.invoke(ClassKit.isStatic(method) ? null : object, actualArgs); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1102,7 +1102,7 @@ public static T invoke(Object object, Method method, Object... args) { public static T invoke(Object object, String methodName, Object... args) { final Method method = getMethodOfObject(object, methodName, args); if (null == method) { - throw new InstrumentException(StringKit.format("No such method: [{}]", methodName)); + throw new InternalException(StringKit.format("No such method: [{}]", methodName)); } return invoke(object, method, args); } diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/RuntimeKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/RuntimeKit.java index c831ffaa8d..14ccbe6995 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/RuntimeKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/RuntimeKit.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.toolkit; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.stream.FastByteOutputStream; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.lang.Normal; @@ -57,9 +57,9 @@ public class RuntimeKit { * * @param cmds 命令列表,每个元素代表一条命令 * @return 执行结果 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static String execForString(String... cmds) throws InstrumentException { + public static String execForString(String... cmds) throws InternalException { return execForString(Charset.systemCharset(), cmds); } @@ -69,9 +69,9 @@ public static String execForString(String... cmds) throws InstrumentException { * @param charset 编码 * @param cmds 命令列表,每个元素代表一条命令 * @return 执行结果 - * @throws InstrumentException 内部处理异常 + * @throws InternalException 内部处理异常 */ - public static String execForString(java.nio.charset.Charset charset, String... cmds) throws InstrumentException { + public static String execForString(java.nio.charset.Charset charset, String... cmds) throws InternalException { return getResult(exec(cmds), charset); } @@ -80,9 +80,9 @@ public static String execForString(java.nio.charset.Charset charset, String... c * * @param cmds 命令列表,每个元素代表一条命令 * @return 执行结果, 按行区分 - * @throws InstrumentException 内部处理异常 + * @throws InternalException 内部处理异常 */ - public static List execForLines(String... cmds) throws InstrumentException { + public static List execForLines(String... cmds) throws InternalException { return execForLines(Charset.systemCharset(), cmds); } @@ -92,9 +92,9 @@ public static List execForLines(String... cmds) throws InstrumentExcepti * @param charset 编码 * @param cmds 命令列表,每个元素代表一条命令 * @return 执行结果, 按行区分 - * @throws InstrumentException 内部处理异常 + * @throws InternalException 内部处理异常 */ - public static List execForLines(java.nio.charset.Charset charset, String... cmds) throws InstrumentException { + public static List execForLines(java.nio.charset.Charset charset, String... cmds) throws InternalException { return getResultLines(exec(cmds), charset); } @@ -122,7 +122,7 @@ public static Process exec(String... cmds) { try { process = new ProcessBuilder(cmds).redirectErrorStream(true).start(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return process; } @@ -163,7 +163,7 @@ public static Process exec(String[] envp, File dir, String... cmds) { try { return Runtime.getRuntime().exec(cmds, envp, dir); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -280,7 +280,7 @@ public static void addShutdownHook(Runnable hook) { public static int getPid() { final String processName = ManagementFactory.getRuntimeMXBean().getName(); if (StringKit.isBlank(processName)) { - throw new InstrumentException("Process name is blank!"); + throw new InternalException("Process name is blank!"); } final int atIndex = processName.indexOf('@'); if (atIndex > 0) { @@ -495,7 +495,7 @@ public static String getStackTraceOneLine(Throwable throwable, int limit) { * @return 堆栈转为的字符串 */ public static String getStackTrace(Throwable throwable) { - return getStackTrace(throwable, 3000); + return getStackTrace(throwable, -1); } /** diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/StreamKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/StreamKit.java index 5d7d0866b6..42dd901c77 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/StreamKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/StreamKit.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.toolkit; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.lang.Normal; @@ -136,7 +136,7 @@ public static String readAll(Reader reader) { } return sb.toString(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { safeClose(reader); } @@ -280,7 +280,7 @@ public static String readAndClose(Reader reader) { try { return read(reader).toString(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { safeClose(reader); } @@ -297,7 +297,7 @@ public static byte[] readAndClose(InputStream ins) { try { bytes = read(ins); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { StreamKit.safeClose(ins); } @@ -317,7 +317,7 @@ public static int readAndClose(InputStreamReader reader, StringBuilder sb) { try { return read(reader, sb); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { safeClose(reader); } @@ -335,7 +335,7 @@ public static void writeAndClose(Writer writer, CharSequence cs) { try { write(writer, cs); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { safeClose(writer); } @@ -354,7 +354,7 @@ public static long writeAndClose(OutputStream ops, InputStream ins) { try { return write(ops, ins); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { safeClose(ops); safeClose(ins); @@ -374,7 +374,7 @@ public static long writeAndClose(Writer writer, Reader reader) { try { return write(writer, reader); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { safeClose(writer); safeClose(reader); @@ -393,7 +393,7 @@ public static void writeAndClose(OutputStream ops, byte[] bytes) { try { write(ops, bytes); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { safeClose(ops); } @@ -403,7 +403,7 @@ public static long writeAndClose(OutputStream ops, InputStream ins, int buf) { try { return write(ops, ins, buf); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { safeClose(ops); safeClose(ins); @@ -540,7 +540,7 @@ public static InputStream utf8filte(InputStream in) { } return pis; } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -554,7 +554,7 @@ public static OutputStream fileOut(File file) { try { return buff(new FileOutputStream(file)); } catch (FileNotFoundException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -568,7 +568,7 @@ public static void appendWriteAndClose(File f, String text) { fw = new FileWriter(f, true); fw.write(text); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { safeClose(fw); } @@ -801,7 +801,7 @@ public static Stream of(Path path, java.nio.charset.Charset charset) { try { return Files.lines(path, charset); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/StringKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/StringKit.java index d0bacbd5af..b27f7b17bf 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/StringKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/StringKit.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.toolkit; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.lang.Normal; import org.aoju.bus.core.lang.RegEx; @@ -400,7 +400,7 @@ public static byte[] base64ToByte(String text) { } return Base64.getDecoder().decode(text); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -418,7 +418,7 @@ public static String base64ToString(String text) { } return new String(base64ToByte(text), Charset.UTF_8); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -437,7 +437,7 @@ public static String base64ToString(String text, String charset) { } return new String(base64ToByte(text), charset); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/SwingKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/SwingKit.java index 2c65cbd234..75f171378b 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/SwingKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/SwingKit.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.toolkit; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.swing.ClipboardListener; import org.aoju.bus.core.swing.ClipboardMonitor; import org.aoju.bus.core.swing.ImageSelection; @@ -56,7 +56,7 @@ public class SwingKit { try { robot = new Robot(); } catch (AWTException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -280,7 +280,7 @@ public static void browse(URI uri) { try { dsktop.browse(uri); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -294,7 +294,7 @@ public static void open(File file) { try { dsktop.open(file); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -308,7 +308,7 @@ public static void edit(File file) { try { dsktop.edit(file); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -322,7 +322,7 @@ public static void print(File file) { try { dsktop.print(file); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -336,7 +336,7 @@ public static void mail(String mailAddress) { try { dsktop.mail(UriKit.toURI(mailAddress)); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -390,7 +390,7 @@ public static Object get(Transferable content, DataFlavor flavor) { try { return content.getTransferData(flavor); } catch (UnsupportedFlavorException | IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } return null; diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/TreeKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/TreeKit.java index 8f04462a25..6f3b59ea13 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/TreeKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/TreeKit.java @@ -125,8 +125,7 @@ public static List> build(List list, E rootId, NodeConfig node * @return {@link Tree} */ public static Tree buildSingle(List list, E rootId, NodeConfig nodeConfig, NodeParser nodeParser) { - return TreeBuilder.of(rootId, nodeConfig) - .append(list, nodeParser).build(); + return TreeBuilder.of(rootId, nodeConfig).append(list, rootId, nodeParser).build(); } /** diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/UriKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/UriKit.java index be781a2ff2..fd08cee3f0 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/UriKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/UriKit.java @@ -26,7 +26,7 @@ package org.aoju.bus.core.toolkit; import org.aoju.bus.core.convert.Convert; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.*; import org.aoju.bus.core.map.TableMap; @@ -201,17 +201,17 @@ public static URL url(String url) { * * @param uri {@link URI} * @return URL对象 - * @throws InstrumentException {@link MalformedURLException}包装,URI格式有问题时抛出 + * @throws InternalException {@link MalformedURLException}包装,URI格式有问题时抛出 * @see URI#toURL() */ - public static URL url(URI uri) throws InstrumentException { + public static URL url(URI uri) throws InternalException { if (null == uri) { return null; } try { return uri.toURL(); } catch (MalformedURLException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -240,7 +240,7 @@ public static URL url(String url, URLStreamHandler handler) { try { return new File(url).toURI().toURL(); } catch (MalformedURLException ex2) { - throw new InstrumentException(e); + throw new InternalException(e); } } } @@ -285,14 +285,14 @@ public static URL getURL(String pathBaseClassLoader) { * * @param file URL对应的文件对象 * @return URL - * @throws InstrumentException MalformedURLException + * @throws InternalException MalformedURLException */ public static URL getURL(File file) { Assert.notNull(file, "File is null !"); try { return file.toURI().toURL(); } catch (MalformedURLException e) { - throw new InstrumentException("Error occured when get URL!"); + throw new InternalException("Error occured when get URL!"); } } @@ -301,7 +301,7 @@ public static URL getURL(File file) { * * @param files URL对应的文件对象 * @return URL - * @throws InstrumentException MalformedURLException + * @throws InternalException MalformedURLException */ public static URL[] getURL(File... files) { final URL[] urls = new URL[files.length]; @@ -310,7 +310,7 @@ public static URL[] getURL(File... files) { urls[i] = files[i].toURI().toURL(); } } catch (MalformedURLException e) { - throw new InstrumentException("Error occured when get URL!"); + throw new InternalException("Error occured when get URL!"); } return urls; @@ -345,7 +345,7 @@ public static String formatUrl(String url) { * @param baseUrl 基准URL * @param relativePath 相对URL * @return 相对路径 - * @throws InstrumentException MalformedURLException + * @throws InternalException MalformedURLException */ public static String complateUrl(String baseUrl, String relativePath) { baseUrl = formatUrl(baseUrl); @@ -358,7 +358,7 @@ public static String complateUrl(String baseUrl, String relativePath) { final URL parseUrl = new URL(absoluteUrl, relativePath); return parseUrl.toString(); } catch (MalformedURLException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -368,9 +368,9 @@ public static String complateUrl(String baseUrl, String relativePath) { * * @param url URL * @return 编码后的URL - * @throws InstrumentException UnsupportedEncodingException + * @throws InternalException UnsupportedEncodingException */ - public static String encode(String url) throws InstrumentException { + public static String encode(String url) throws InternalException { return encode(url, Charset.DEFAULT_UTF_8); } @@ -400,7 +400,7 @@ public static String encodeAll(String url, java.nio.charset.Charset charset) { } return URLEncoder.encode(url, charset.toString()); } catch (UnsupportedEncodingException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -409,7 +409,7 @@ public static String encodeAll(String url, java.nio.charset.Charset charset) { * * @param uriStr URI路径 * @return path - * @throws InstrumentException 包装URISyntaxException + * @throws InternalException 包装URISyntaxException */ public static String getPath(String uriStr) { return toURI(uriStr).getPath(); @@ -432,7 +432,7 @@ public static String getDecodedPath(URL url) { try { // URL对象的getPath方法对于包含中文或空格的问题 path = toURI(url).getPath(); - } catch (InstrumentException e) { + } catch (InternalException e) { // ignore } return (null != path) ? path : url.getPath(); @@ -443,16 +443,16 @@ public static String getDecodedPath(URL url) { * * @param url URL * @return URI - * @throws InstrumentException 包装URISyntaxException + * @throws InternalException 包装URISyntaxException */ - public static URI toURI(URL url) throws InstrumentException { + public static URI toURI(URL url) throws InternalException { if (null == url) { return null; } try { return url.toURI(); } catch (URISyntaxException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -461,13 +461,13 @@ public static URI toURI(URL url) throws InstrumentException { * * @param location 字符串路径 * @return URI - * @throws InstrumentException 包装URISyntaxException + * @throws InternalException 包装URISyntaxException */ - public static URI toURI(String location) throws InstrumentException { + public static URI toURI(String location) throws InternalException { try { return new URI(location.replace(Symbol.SPACE, "%20")); } catch (URISyntaxException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -522,7 +522,7 @@ public static InputStream getStream(URL url) { try { return url.openStream(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -548,7 +548,7 @@ public static JarFile getJarFile(URL url) { JarURLConnection urlConnection = (JarURLConnection) url.openConnection(); return urlConnection.getJarFile(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1408,7 +1408,7 @@ public static URI getHost(URL url) { try { return new URI(url.getProtocol(), url.getHost(), null, null); } catch (URISyntaxException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1941,7 +1941,7 @@ public Path setWithEndTag(boolean withEngTag) { * @return 节点列表 */ public List getSegments() { - return this.segments; + return ObjectKit.defaultIfNull(this.segments, CollKit.empty()); } /** diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/XmlKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/XmlKit.java index 34bfb0a271..ba842668a4 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/XmlKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/XmlKit.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.toolkit; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.*; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -77,10 +77,10 @@ public class XmlKit { public static Document readXML(File file) { Assert.notNull(file, "Xml file is null !"); if (false == file.exists()) { - throw new InstrumentException("File [{}] not a exist!", file.getAbsolutePath()); + throw new InternalException("File [{}] not a exist!", file.getAbsolutePath()); } if (false == file.isFile()) { - throw new InstrumentException("[{}] not a file!", file.getAbsolutePath()); + throw new InternalException("[{}] not a file!", file.getAbsolutePath()); } try { @@ -146,7 +146,7 @@ public static Document readXML(InputSource source) { try { return builder.parse(source); } catch (Exception e) { - throw new InstrumentException("Parse XML from stream error!"); + throw new InternalException("Parse XML from stream error!"); } } @@ -226,7 +226,7 @@ public static void readBySax(InputSource source, ContentHandler contentHandler) reader.setContentHandler(contentHandler); reader.parse(source); } catch (IOException | ParserConfigurationException | SAXException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -374,7 +374,7 @@ public static String toString(Node doc, String charset, boolean isPretty, boolea try { write(doc, writer, charset, isPretty ? 2 : 0, omitXmlDeclaration); } catch (Exception e) { - throw new InstrumentException("Trans xml document to string error!"); + throw new InternalException("Trans xml document to string error!"); } return writer.toString(); } @@ -522,7 +522,7 @@ public static void transform(Source source, Result result, String charset, int i } xformer.transform(source, result); } catch (Exception e) { - throw new InstrumentException("Trans xml document to string error!"); + throw new InternalException("Trans xml document to string error!"); } } @@ -682,7 +682,7 @@ public static Object getByXPath(String expression, Object source, QName returnTy return xPath.evaluate(expression, source, returnType); } } catch (XPathExpressionException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -918,7 +918,7 @@ public static DocumentBuilder builder() { try { builder = dbf.newDocumentBuilder(); } catch (Exception e) { - throw new InstrumentException("Create xml document error!"); + throw new InternalException("Create xml document error!"); } return builder; } diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/ZipKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/ZipKit.java index d118438caf..e4e4423d18 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/ZipKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/ZipKit.java @@ -27,7 +27,7 @@ import org.aoju.bus.core.collection.EnumerationIterator; import org.aoju.bus.core.compress.*; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.resource.Resource; import org.aoju.bus.core.lang.Normal; import org.aoju.bus.core.lang.Symbol; @@ -67,9 +67,9 @@ public class ZipKit { * * @param srcPath 源文件路径 * @return 打包好的压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(String srcPath) throws InstrumentException { + public static File zip(String srcPath) throws InternalException { return zip(srcPath, DEFAULT_CHARSET); } @@ -79,9 +79,9 @@ public static File zip(String srcPath) throws InstrumentException { * @param srcPath 源文件路径 * @param charset 编码 * @return 打包好的压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(String srcPath, java.nio.charset.Charset charset) throws InstrumentException { + public static File zip(String srcPath, java.nio.charset.Charset charset) throws InternalException { return zip(FileKit.file(srcPath), charset); } @@ -90,9 +90,9 @@ public static File zip(String srcPath, java.nio.charset.Charset charset) throws * * @param srcFile 源文件或目录 * @return 打包好的压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(File srcFile) throws InstrumentException { + public static File zip(File srcFile) throws InternalException { return zip(srcFile, DEFAULT_CHARSET); } @@ -102,9 +102,9 @@ public static File zip(File srcFile) throws InstrumentException { * @param srcFile 源文件或目录 * @param charset 编码 * @return 打包好的压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(File srcFile, java.nio.charset.Charset charset) throws InstrumentException { + public static File zip(File srcFile, java.nio.charset.Charset charset) throws InternalException { final File zipFile = FileKit.file(srcFile.getParentFile(), FileKit.getPrefix(srcFile) + ".zip"); zip(zipFile, charset, false, srcFile); return zipFile; @@ -117,9 +117,9 @@ public static File zip(File srcFile, java.nio.charset.Charset charset) throws In * @param srcPath 要压缩的源文件路径 如果压缩一个文件,则为该文件的全路径;如果压缩一个目录,则为该目录的顶层目录路径 * @param zipPath 压缩文件保存的路径,包括文件名 注意:zipPath不能是srcPath路径下的子文件夹 * @return 压缩好的Zip文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(String srcPath, String zipPath) throws InstrumentException { + public static File zip(String srcPath, String zipPath) throws InternalException { return zip(srcPath, zipPath, false); } @@ -130,9 +130,9 @@ public static File zip(String srcPath, String zipPath) throws InstrumentExceptio * @param zipPath 压缩文件保存的路径,包括文件名 注意:zipPath不能是srcPath路径下的子文件夹 * @param withSrcDir 是否包含被打包目录 * @return 压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(String srcPath, String zipPath, boolean withSrcDir) throws InstrumentException { + public static File zip(String srcPath, String zipPath, boolean withSrcDir) throws InternalException { return zip(srcPath, zipPath, DEFAULT_CHARSET, withSrcDir); } @@ -144,9 +144,9 @@ public static File zip(String srcPath, String zipPath, boolean withSrcDir) throw * @param charset 编码 * @param withSrcDir 是否包含被打包目录 * @return 压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(String srcPath, String zipPath, java.nio.charset.Charset charset, boolean withSrcDir) throws InstrumentException { + public static File zip(String srcPath, String zipPath, java.nio.charset.Charset charset, boolean withSrcDir) throws InternalException { final File srcFile = FileKit.file(srcPath); final File zipFile = FileKit.file(zipPath); zip(zipFile, charset, withSrcDir, srcFile); @@ -161,9 +161,9 @@ public static File zip(String srcPath, String zipPath, java.nio.charset.Charset * @param withSrcDir 是否包含被打包目录,只针对压缩目录有效 若为false,则只压缩目录下的文件或目录,为true则将本目录也压缩 * @param srcFiles 要压缩的源文件或目录 * @return 压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(File zipFile, boolean withSrcDir, File... srcFiles) throws InstrumentException { + public static File zip(File zipFile, boolean withSrcDir, File... srcFiles) throws InternalException { return zip(zipFile, DEFAULT_CHARSET, withSrcDir, srcFiles); } @@ -175,9 +175,9 @@ public static File zip(File zipFile, boolean withSrcDir, File... srcFiles) throw * @param withSrcDir 是否包含被打包目录,只针对压缩目录有效 若为false,则只压缩目录下的文件或目录,为true则将本目录也压缩 * @param srcFiles 要压缩的源文件或目录 如果压缩一个文件,则为该文件的全路径;如果压缩一个目录,则为该目录的顶层目录路径 * @return 压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(File zipFile, java.nio.charset.Charset charset, boolean withSrcDir, File... srcFiles) throws InstrumentException { + public static File zip(File zipFile, java.nio.charset.Charset charset, boolean withSrcDir, File... srcFiles) throws InternalException { return zip(zipFile, charset, withSrcDir, null, srcFiles); } @@ -190,9 +190,9 @@ public static File zip(File zipFile, java.nio.charset.Charset charset, boolean w * @param filter 文件过滤器,通过实现此接口,自定义要过滤的文件(过滤掉哪些文件或文件夹不加入压缩) * @param srcFiles 要压缩的源文件或目录。如果压缩一个文件,则为该文件的全路径;如果压缩一个目录,则为该目录的顶层目录路径 * @return 压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(File zipFile, java.nio.charset.Charset charset, boolean withSrcDir, FileFilter filter, File... srcFiles) throws InstrumentException { + public static File zip(File zipFile, java.nio.charset.Charset charset, boolean withSrcDir, FileFilter filter, File... srcFiles) throws InternalException { validateFiles(zipFile, srcFiles); ZipWriter.of(zipFile, charset).add(withSrcDir, filter, srcFiles).close(); @@ -233,9 +233,9 @@ public static void zip(ZipOutputStream zipOutputStream, boolean withSrcDir, File * @param path 流数据在压缩文件中的路径或文件名 * @param data 要压缩的数据 * @return 压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(File zipFile, String path, String data) throws InstrumentException { + public static File zip(File zipFile, String path, String data) throws InternalException { return zip(zipFile, path, data, DEFAULT_CHARSET); } @@ -247,9 +247,9 @@ public static File zip(File zipFile, String path, String data) throws Instrument * @param data 要压缩的数据 * @param charset 编码 * @return 压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(File zipFile, String path, String data, java.nio.charset.Charset charset) throws InstrumentException { + public static File zip(File zipFile, String path, String data, java.nio.charset.Charset charset) throws InternalException { return zip(zipFile, path, IoKit.toStream(data, charset), charset); } @@ -261,9 +261,9 @@ public static File zip(File zipFile, String path, String data, java.nio.charset. * @param path 流数据在压缩文件中的路径或文件名 * @param in 要压缩的源 * @return 压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(File zipFile, String path, InputStream in) throws InstrumentException { + public static File zip(File zipFile, String path, InputStream in) throws InternalException { return zip(zipFile, path, in, DEFAULT_CHARSET); } @@ -275,9 +275,9 @@ public static File zip(File zipFile, String path, InputStream in) throws Instrum * @param in 要压缩的源 * @param charset 编码 * @return 压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(File zipFile, String path, InputStream in, java.nio.charset.Charset charset) throws InstrumentException { + public static File zip(File zipFile, String path, InputStream in, java.nio.charset.Charset charset) throws InternalException { return zip(zipFile, new String[]{path}, new InputStream[]{in}, charset); } @@ -289,9 +289,9 @@ public static File zip(File zipFile, String path, InputStream in, java.nio.chars * @param paths 流数据在压缩文件中的路径或文件名 * @param ins 要压缩的源,添加完成后自动关闭流 * @return 压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(File zipFile, String[] paths, InputStream[] ins) throws InstrumentException { + public static File zip(File zipFile, String[] paths, InputStream[] ins) throws InternalException { return zip(zipFile, paths, ins, DEFAULT_CHARSET); } @@ -304,9 +304,9 @@ public static File zip(File zipFile, String[] paths, InputStream[] ins) throws I * @param ins 要压缩的源 * @param charset 编码 * @return 压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(File zipFile, String[] paths, InputStream[] ins, java.nio.charset.Charset charset) throws InstrumentException { + public static File zip(File zipFile, String[] paths, InputStream[] ins, java.nio.charset.Charset charset) throws InternalException { if (ArrayKit.isEmpty(paths) || ArrayKit.isEmpty(ins)) { throw new IllegalArgumentException("Paths or ins is empty !"); } @@ -350,9 +350,9 @@ public static void zip(OutputStream out, String[] paths, InputStream[] ins) { * @param zipOutputStream 目标流,压缩完成不关闭 * @param paths 流数据在压缩文件中的路径或文件名 * @param ins 要压缩的源,添加完成后自动关闭流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static void zip(ZipOutputStream zipOutputStream, String[] paths, InputStream[] ins) throws InstrumentException { + public static void zip(ZipOutputStream zipOutputStream, String[] paths, InputStream[] ins) throws InternalException { if (ArrayKit.isEmpty(paths) || ArrayKit.isEmpty(ins)) { throw new IllegalArgumentException("Paths or ins is empty !"); } @@ -375,9 +375,9 @@ public static void zip(ZipOutputStream zipOutputStream, String[] paths, InputStr * @param charset 编码 * @param resources 需要压缩的资源,资源的路径为{@link Resource#getName()} * @return 压缩文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File zip(File zipFile, Charset charset, Resource... resources) throws InstrumentException { + public static File zip(File zipFile, Charset charset, Resource... resources) throws InternalException { ZipWriter.of(zipFile, charset).add(resources).close(); return zipFile; } @@ -387,9 +387,9 @@ public static File zip(File zipFile, Charset charset, Resource... resources) thr * * @param zipFilePath 压缩文件路径 * @return 解压的目录 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File unzip(String zipFilePath) throws InstrumentException { + public static File unzip(String zipFilePath) throws InternalException { return unzip(zipFilePath, DEFAULT_CHARSET); } @@ -399,9 +399,9 @@ public static File unzip(String zipFilePath) throws InstrumentException { * @param zipFilePath 压缩文件路径 * @param charset 编码 * @return 解压的目录 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File unzip(String zipFilePath, java.nio.charset.Charset charset) throws InstrumentException { + public static File unzip(String zipFilePath, java.nio.charset.Charset charset) throws InternalException { return unzip(FileKit.file(zipFilePath), charset); } @@ -410,9 +410,9 @@ public static File unzip(String zipFilePath, java.nio.charset.Charset charset) t * * @param zipFile 压缩文件 * @return 解压的目录 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File unzip(File zipFile) throws InstrumentException { + public static File unzip(File zipFile) throws InternalException { return unzip(zipFile, DEFAULT_CHARSET); } @@ -422,9 +422,9 @@ public static File unzip(File zipFile) throws InstrumentException { * @param zipFile 压缩文件 * @param charset 编码 * @return 解压的目录 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File unzip(File zipFile, java.nio.charset.Charset charset) throws InstrumentException { + public static File unzip(File zipFile, java.nio.charset.Charset charset) throws InternalException { return unzip(zipFile, FileKit.file(zipFile.getParentFile(), FileKit.getPrefix(zipFile)), charset); } @@ -434,9 +434,9 @@ public static File unzip(File zipFile, java.nio.charset.Charset charset) throws * @param zipFilePath 压缩文件的路径 * @param outFileDir 解压到的目录 * @return 解压的目录 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File unzip(String zipFilePath, String outFileDir) throws InstrumentException { + public static File unzip(String zipFilePath, String outFileDir) throws InternalException { return unzip(zipFilePath, outFileDir, DEFAULT_CHARSET); } @@ -447,9 +447,9 @@ public static File unzip(String zipFilePath, String outFileDir) throws Instrumen * @param outFileDir 解压到的目录 * @param charset 编码 * @return 解压的目录 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File unzip(String zipFilePath, String outFileDir, java.nio.charset.Charset charset) throws InstrumentException { + public static File unzip(String zipFilePath, String outFileDir, java.nio.charset.Charset charset) throws InternalException { return unzip(FileKit.file(zipFilePath), FileKit.mkdir(outFileDir), charset); } @@ -459,9 +459,9 @@ public static File unzip(String zipFilePath, String outFileDir, java.nio.charset * @param zipFile zip文件 * @param outFile 解压到的目录 * @return 解压的目录 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File unzip(File zipFile, File outFile) throws InstrumentException { + public static File unzip(File zipFile, File outFile) throws InternalException { return unzip(zipFile, outFile, DEFAULT_CHARSET); } @@ -472,9 +472,9 @@ public static File unzip(File zipFile, File outFile) throws InstrumentException * @param outFile 解压到的目录 * @param charset 编码 * @return 解压的目录 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static File unzip(File zipFile, File outFile, java.nio.charset.Charset charset) throws InstrumentException { + public static File unzip(File zipFile, File outFile, java.nio.charset.Charset charset) throws InternalException { return unzip(zipFile(zipFile, charset), outFile); } @@ -484,7 +484,7 @@ public static File unzip(File zipFile, File outFile, java.nio.charset.Charset ch * @param zipFile zip文件,附带编码信息,使用完毕自动关闭 * @param outFile 解压到的目录 * @return 解压的目录 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ public static File unzip(ZipFile zipFile, File outFile) { return unzip(zipFile, outFile, -1); @@ -607,9 +607,9 @@ public static byte[] unzipFileBytes(File zipFile, java.nio.charset.Charset chars * @param content 被压缩的字符串 * @param charset 编码 * @return 压缩后的字节流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static byte[] gzip(String content, String charset) throws InstrumentException { + public static byte[] gzip(String content, String charset) throws InternalException { return gzip(StringKit.bytes(content, charset)); } @@ -618,9 +618,9 @@ public static byte[] gzip(String content, String charset) throws InstrumentExcep * * @param buf 被压缩的字节流 * @return 压缩后的字节流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static byte[] gzip(byte[] buf) throws InstrumentException { + public static byte[] gzip(byte[] buf) throws InternalException { return gzip(new ByteArrayInputStream(buf), buf.length); } @@ -629,9 +629,9 @@ public static byte[] gzip(byte[] buf) throws InstrumentException { * * @param file 被压缩的文件 * @return 压缩后的字节流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static byte[] gzip(File file) throws InstrumentException { + public static byte[] gzip(File file) throws InternalException { BufferedInputStream in = null; try { in = FileKit.getInputStream(file); @@ -646,9 +646,9 @@ public static byte[] gzip(File file) throws InstrumentException { * * @param in 被压缩的流 * @return 压缩后的字节流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static byte[] gzip(InputStream in) throws InstrumentException { + public static byte[] gzip(InputStream in) throws InternalException { return gzip(in, DEFAULT_BYTE_ARRAY_LENGTH); } @@ -658,9 +658,9 @@ public static byte[] gzip(InputStream in) throws InstrumentException { * @param in 被压缩的流 * @param length 预估长度 * @return 压缩后的字节流 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static byte[] gzip(InputStream in, int length) throws InstrumentException { + public static byte[] gzip(InputStream in, int length) throws InternalException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(length); Gzip.of(in, bos).gzip().close(); return bos.toByteArray(); @@ -672,9 +672,9 @@ public static byte[] gzip(InputStream in, int length) throws InstrumentException * @param buf 压缩过的字节流 * @param charset 编码 * @return 解压后的字符串 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static String unGzip(byte[] buf, String charset) throws InstrumentException { + public static String unGzip(byte[] buf, String charset) throws InternalException { return StringKit.toString(unGzip(buf), charset); } @@ -683,9 +683,9 @@ public static String unGzip(byte[] buf, String charset) throws InstrumentExcepti * * @param buf buf * @return bytes - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static byte[] unGzip(byte[] buf) throws InstrumentException { + public static byte[] unGzip(byte[] buf) throws InternalException { return unGzip(new ByteArrayInputStream(buf), buf.length); } @@ -694,9 +694,9 @@ public static byte[] unGzip(byte[] buf) throws InstrumentException { * * @param in Gzip数据 * @return 解压后的数据 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static byte[] unGzip(InputStream in) throws InstrumentException { + public static byte[] unGzip(InputStream in) throws InternalException { return unGzip(in, DEFAULT_BYTE_ARRAY_LENGTH); } @@ -706,9 +706,9 @@ public static byte[] unGzip(InputStream in) throws InstrumentException { * @param in Gzip数据 * @param length 估算长度,如果无法确定请传入{@link #DEFAULT_BYTE_ARRAY_LENGTH} * @return 解压后的数据 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static byte[] unGzip(InputStream in, int length) throws InstrumentException { + public static byte[] unGzip(InputStream in, int length) throws InternalException { ByteArrayOutputStream bos = new ByteArrayOutputStream(length); Gzip.of(in, bos).unGzip().close(); return bos.toByteArray(); @@ -861,7 +861,7 @@ public static InputStream get(ZipFile zipFile, ZipEntry zipEntry) { try { return zipFile.getInputStream(zipEntry); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -914,7 +914,7 @@ public static ZipFile zipFile(File file, Charset charset) { try { return new ZipFile(file, ObjectKit.defaultIfNull(charset, org.aoju.bus.core.lang.Charset.UTF_8)); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -979,14 +979,10 @@ public static void append(Path zipPath, Path appendFilePath, CopyOption... optio * @param path 文件路径,可以是目录或Zip文件等 * @return {@link FileSystem} */ - public static FileSystem create(String path) { - try { - return FileSystems.newFileSystem( - Paths.get(path).toUri(), - MapKit.of("create", "true")); - } catch (IOException e) { - throw new InstrumentException(e); - } + public static FileSystem create(String path) throws IOException { + return FileSystems.newFileSystem( + Paths.get(path).toUri(), + MapKit.of("create", "true")); } /** @@ -1018,7 +1014,7 @@ public static FileSystem createZip(String path, Charset charset) { return FileSystems.newFileSystem( URI.create("jar:" + Paths.get(path).toUri()), env); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -1028,9 +1024,9 @@ public static FileSystem createZip(String path, Charset charset) { * @param zipFile 压缩后的产生的文件路径 * @param srcFiles 被压缩的文件或目录 */ - private static void validateFiles(File zipFile, File... srcFiles) throws InstrumentException { + private static void validateFiles(File zipFile, File... srcFiles) throws InternalException { if (zipFile.isDirectory()) { - throw new InstrumentException("Zip file [{}] must not be a directory !", zipFile.getAbsoluteFile()); + throw new InternalException("Zip file [{}] must not be a directory !", zipFile.getAbsoluteFile()); } for (File srcFile : srcFiles) { @@ -1038,7 +1034,7 @@ private static void validateFiles(File zipFile, File... srcFiles) throws Instrum continue; } if (false == srcFile.exists()) { - throw new InstrumentException(StringKit.format("File [{}] not exist!", srcFile.getAbsolutePath())); + throw new InternalException(StringKit.format("File [{}] not exist!", srcFile.getAbsolutePath())); } // 当 zipFile = new File("temp.zip") 时, zipFile.getParentFile() == null @@ -1051,7 +1047,7 @@ private static void validateFiles(File zipFile, File... srcFiles) throws Instrum // 压缩文件不能位于被压缩的目录内 if (srcFile.isDirectory() && FileKit.isSub(srcFile, parentFile)) { - throw new InstrumentException("Zip file path [{}] must not be the child directory of [{}] !", zipFile.getPath(), srcFile.getPath()); + throw new InternalException("Zip file path [{}] must not be the child directory of [{}] !", zipFile.getPath(), srcFile.getPath()); } } } @@ -1062,9 +1058,9 @@ private static void validateFiles(File zipFile, File... srcFiles) throws Instrum * @param zipFile Zip文件 * @param zipEntry zip文件中的子文件 * @param outItemFile 输出到的文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - private static void write(ZipFile zipFile, ZipEntry zipEntry, File outItemFile) throws InstrumentException { + private static void write(ZipFile zipFile, ZipEntry zipEntry, File outItemFile) throws InternalException { FileKit.writeFromStream(get(zipFile, zipEntry), outItemFile); } diff --git a/bus-cron/pom.xml b/bus-cron/pom.xml index 0fab433a96..7c20306bce 100755 --- a/bus-cron/pom.xml +++ b/bus-cron/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-cron - 6.5.6 + 6.5.8 jar ${project.artifactId} diff --git a/bus-cron/src/main/java/org/aoju/bus/cron/Builder.java b/bus-cron/src/main/java/org/aoju/bus/cron/Builder.java index 088a11a44f..c82ecefb8a 100644 --- a/bus-cron/src/main/java/org/aoju/bus/cron/Builder.java +++ b/bus-cron/src/main/java/org/aoju/bus/cron/Builder.java @@ -26,7 +26,7 @@ package org.aoju.bus.cron; import org.aoju.bus.core.exception.CrontabException; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.cron.factory.Task; import org.aoju.bus.cron.pattern.CronPattern; @@ -72,7 +72,7 @@ public static void setCronSetting(PopSetting cronSetting) { public static void setCronSetting(String cronSettingPath) { try { crontabSetting = new PopSetting(cronSettingPath, Charset.UTF_8, false); - } catch (InstrumentException e) { + } catch (InternalException e) { // ignore setting file parse error and no config error } } diff --git a/bus-crypto/pom.xml b/bus-crypto/pom.xml index 4c32e5d199..5ed97a6f9c 100755 --- a/bus-crypto/pom.xml +++ b/bus-crypto/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-crypto - 6.5.6 + 6.5.8 jar ${project.artifactId} diff --git a/bus-crypto/src/main/java/org/aoju/bus/crypto/Registry.java b/bus-crypto/src/main/java/org/aoju/bus/crypto/Registry.java index 45c2489bd9..dcddb3b418 100755 --- a/bus-crypto/src/main/java/org/aoju/bus/crypto/Registry.java +++ b/bus-crypto/src/main/java/org/aoju/bus/crypto/Registry.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.crypto; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Algorithm; import org.aoju.bus.core.toolkit.ObjectKit; import org.aoju.bus.crypto.provider.*; @@ -64,11 +64,11 @@ public final class Registry { */ public static void register(String name, Provider object) { if (ALGORITHM_CACHE.containsKey(name)) { - throw new InstrumentException("Repeat registration of components with the same name:" + name); + throw new InternalException("Repeat registration of components with the same name:" + name); } Class clazz = object.getClass(); if (ALGORITHM_CACHE.containsKey(clazz.getSimpleName())) { - throw new InstrumentException("Repeat registration of components with the same name:" + clazz); + throw new InternalException("Repeat registration of components with the same name:" + clazz); } ALGORITHM_CACHE.putIfAbsent(name, object); } diff --git a/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/AESProvider.java b/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/AESProvider.java index 65be8c2e98..0c8971a639 100755 --- a/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/AESProvider.java +++ b/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/AESProvider.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.crypto.provider; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.StringKit; import org.aoju.bus.crypto.Provider; import org.aoju.bus.crypto.symmetric.AES; @@ -51,7 +51,7 @@ public class AESProvider implements Provider { @Override public byte[] encrypt(String key, byte[] content) { if (StringKit.isEmpty(key)) { - throw new InstrumentException("key is null!"); + throw new InternalException("key is null!"); } AES aes = new AES(key.getBytes()); return aes.encrypt(content); @@ -67,7 +67,7 @@ public byte[] encrypt(String key, byte[] content) { @Override public byte[] decrypt(String key, byte[] content) { if (StringKit.isEmpty(key)) { - throw new InstrumentException("key is null!"); + throw new InternalException("key is null!"); } AES aes = new AES(key.getBytes()); return aes.decrypt(content); diff --git a/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/DESProvider.java b/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/DESProvider.java index e9e30dbbbc..17a0724ff9 100755 --- a/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/DESProvider.java +++ b/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/DESProvider.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.crypto.provider; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.StringKit; import org.aoju.bus.crypto.Provider; import org.aoju.bus.crypto.symmetric.DES; @@ -47,7 +47,7 @@ public class DESProvider implements Provider { @Override public byte[] encrypt(String key, byte[] content) { if (StringKit.isEmpty(key)) { - throw new InstrumentException("key is null!"); + throw new InternalException("key is null!"); } DES des = new DES(key.getBytes()); return des.encrypt(content); @@ -63,7 +63,7 @@ public byte[] encrypt(String key, byte[] content) { @Override public byte[] decrypt(String key, byte[] content) { if (StringKit.isEmpty(key)) { - throw new InstrumentException("key is null!"); + throw new InternalException("key is null!"); } DES des = new DES(key.getBytes()); return des.decrypt(content); diff --git a/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/RC4Provider.java b/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/RC4Provider.java index b18b6a625c..d1b03fb603 100755 --- a/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/RC4Provider.java +++ b/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/RC4Provider.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.crypto.provider; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.toolkit.StringKit; import org.aoju.bus.crypto.Provider; @@ -52,7 +52,7 @@ public class RC4Provider implements Provider { @Override public byte[] encrypt(String key, byte[] content) { if (StringKit.isEmpty(key)) { - throw new InstrumentException("key is null!"); + throw new InternalException("key is null!"); } RC4 rc4 = new RC4(key); return rc4.encrypt(StringKit.toString(content, Charset.UTF_8)); @@ -67,7 +67,7 @@ public byte[] encrypt(String key, byte[] content) { @Override public byte[] decrypt(String key, byte[] content) { if (StringKit.isEmpty(key)) { - throw new InstrumentException("key is null!"); + throw new InternalException("key is null!"); } RC4 rc4 = new RC4(key); return rc4.decrypt(content).getBytes(); diff --git a/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/RSAProvider.java b/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/RSAProvider.java index c820541b5e..a17b825e3f 100755 --- a/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/RSAProvider.java +++ b/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/RSAProvider.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.crypto.provider; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Symbol; import org.aoju.bus.core.toolkit.StringKit; import org.aoju.bus.crypto.Provider; @@ -50,7 +50,7 @@ public class RSAProvider implements Provider { @Override public byte[] encrypt(String key, byte[] content) { if (StringKit.isEmpty(key)) { - throw new InstrumentException("key is null!"); + throw new InternalException("key is null!"); } String[] array = StringKit.splitToArray(key, Symbol.COMMA); RSA rsa = new RSA(array[0], array[1]); @@ -67,7 +67,7 @@ public byte[] encrypt(String key, byte[] content) { @Override public byte[] decrypt(String key, byte[] content) { if (StringKit.isEmpty(key)) { - throw new InstrumentException("key is null!"); + throw new InternalException("key is null!"); } String[] array = StringKit.splitToArray(key, Symbol.COMMA); diff --git a/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/SM2Provider.java b/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/SM2Provider.java index 3d312ed17e..b47a911158 100755 --- a/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/SM2Provider.java +++ b/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/SM2Provider.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.crypto.provider; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Symbol; import org.aoju.bus.core.toolkit.StringKit; import org.aoju.bus.crypto.Provider; @@ -51,7 +51,7 @@ public class SM2Provider implements Provider { @Override public byte[] encrypt(String key, byte[] content) { if (StringKit.isEmpty(key)) { - throw new InstrumentException("key is null!"); + throw new InternalException("key is null!"); } String[] array = StringKit.splitToArray(key, Symbol.COMMA); SM2 sm2 = new SM2(array[0], array[1]); @@ -69,7 +69,7 @@ public byte[] encrypt(String key, byte[] content) { @Override public byte[] decrypt(String key, byte[] content) { if (StringKit.isEmpty(key)) { - throw new InstrumentException("key is null!"); + throw new InternalException("key is null!"); } String[] array = StringKit.splitToArray(key, Symbol.COMMA); SM2 sm2 = new SM2(array[0], array[1]); diff --git a/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/SM4Provider.java b/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/SM4Provider.java index 8640e3324a..6dde129510 100755 --- a/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/SM4Provider.java +++ b/bus-crypto/src/main/java/org/aoju/bus/crypto/provider/SM4Provider.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.crypto.provider; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.HexKit; import org.aoju.bus.core.toolkit.StringKit; import org.aoju.bus.crypto.Provider; @@ -52,7 +52,7 @@ public class SM4Provider implements Provider { @Override public byte[] encrypt(String key, byte[] content) { if (StringKit.isEmpty(key)) { - throw new InstrumentException("key is null!"); + throw new InternalException("key is null!"); } SM4 sm4 = new SM4(HexKit.decodeHex(key)); return sm4.encrypt(content); @@ -67,7 +67,7 @@ public byte[] encrypt(String key, byte[] content) { @Override public byte[] decrypt(String key, byte[] content) { if (StringKit.isEmpty(key)) { - throw new InstrumentException("key is null!"); + throw new InternalException("key is null!"); } SM4 sm4 = new SM4(HexKit.decodeHex(key)); return sm4.decrypt(content); diff --git a/bus-extra/pom.xml b/bus-extra/pom.xml index c1b0957743..ba5e849cb6 100644 --- a/bus-extra/pom.xml +++ b/bus-extra/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-extra - 6.5.6 + 6.5.8 jar ${project.artifactId} diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/captcha/provider/AbstractProvider.java b/bus-extra/src/main/java/org/aoju/bus/extra/captcha/provider/AbstractProvider.java index f888ff7c7c..71181627f6 100644 --- a/bus-extra/src/main/java/org/aoju/bus/extra/captcha/provider/AbstractProvider.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/captcha/provider/AbstractProvider.java @@ -26,7 +26,7 @@ package org.aoju.bus.extra.captcha.provider; import org.aoju.bus.core.codec.Base64; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.FileKit; import org.aoju.bus.core.toolkit.ImageKit; import org.aoju.bus.core.toolkit.IoKit; @@ -158,9 +158,9 @@ public boolean verify(String inputCode) { * 验证码写出到文件 * * @param path 文件路径 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public void write(String path) throws InstrumentException { + public void write(String path) throws InternalException { this.write(FileKit.touch(path)); } @@ -168,13 +168,13 @@ public void write(String path) throws InstrumentException { * 验证码写出到文件 * * @param file 文件 - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public void write(File file) throws InstrumentException { + public void write(File file) throws InternalException { try (OutputStream out = FileKit.getOutputStream(file)) { this.write(out); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/ftp/AbstractFtp.java b/bus-extra/src/main/java/org/aoju/bus/extra/ftp/AbstractFtp.java index d04ebf0820..403d2ebeea 100755 --- a/bus-extra/src/main/java/org/aoju/bus/extra/ftp/AbstractFtp.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/ftp/AbstractFtp.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.extra.ftp; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.lang.Symbol; import org.aoju.bus.core.toolkit.CollKit; @@ -140,7 +140,7 @@ public boolean exist(String path) { final List names; try { names = ls(dir); - } catch (InstrumentException ignore) { + } catch (InternalException ignore) { return false; } return containsIgnoreCase(names, fileName); @@ -190,7 +190,7 @@ public void mkDirs(String dir) { if (false == cd(s)) { exist = false; } - } catch (InstrumentException e) { + } catch (InternalException e) { exist = false; } if (false == exist) { @@ -258,7 +258,7 @@ public void download(String path, File outFile, String tempFileSuffix) { } catch (Throwable e) { // 异常则删除临时文件 FileKit.delete(outFile); - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/ftp/Ftp.java b/bus-extra/src/main/java/org/aoju/bus/extra/ftp/Ftp.java index 735a20536f..9755170e68 100755 --- a/bus-extra/src/main/java/org/aoju/bus/extra/ftp/Ftp.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/ftp/Ftp.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.extra.ftp; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Filter; import org.aoju.bus.core.lang.Normal; @@ -232,7 +232,7 @@ public Ftp init(FtpConfig config, FtpMode mode) { // 登录ftp服务器 client.login(config.getUser(), config.getPassword()); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } final int replyCode = client.getReplyCode(); // 是否成功登录服务器 if (false == FTPReply.isPositiveCompletion(replyCode)) { @@ -241,7 +241,7 @@ public Ftp init(FtpConfig config, FtpMode mode) { } catch (IOException e) { // ignore } - throw new InstrumentException("Login failed for user [{}], reply code is: [{}]", config.getUser(), replyCode); + throw new InternalException("Login failed for user [{}], reply code is: [{}]", config.getUser(), replyCode); } this.client = client; if (null != mode) { @@ -299,7 +299,7 @@ public Ftp reconnectIfTimeout() { String pwd = null; try { pwd = pwd(); - } catch (InstrumentException fex) { + } catch (InternalException fex) { // ignore } @@ -324,7 +324,7 @@ public synchronized boolean cd(String directory) { try { return client.changeWorkingDirectory(directory); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -338,7 +338,7 @@ public String pwd() { try { return client.printWorkingDirectory(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -380,15 +380,15 @@ public List lsFiles(String path, Filter filter) { * * @param path 目录,如果目录不存在,抛出异常 * @return 文件或目录列表 - * @throws InstrumentException 路径不存在 - * @throws InstrumentException IO异常 + * @throws InternalException 路径不存在 + * @throws InternalException IO异常 */ - public FTPFile[] lsFiles(String path) throws InstrumentException { + public FTPFile[] lsFiles(String path) throws InternalException { String pwd = null; if (StringKit.isNotBlank(path)) { pwd = pwd(); if (false == isDir(path)) { - throw new InstrumentException("Change dir to [{}] error, maybe path not exist!", path); + throw new InternalException("Change dir to [{}] error, maybe path not exist!", path); } } @@ -396,7 +396,7 @@ public FTPFile[] lsFiles(String path) throws InstrumentException { try { ftpFiles = this.client.listFiles(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { cd(pwd); } @@ -409,7 +409,7 @@ public boolean mkdir(String dir) { try { return this.client.makeDirectory(dir); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -424,7 +424,7 @@ public boolean existFile(String path) { try { ftpFileArr = client.listFiles(path); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return ArrayKit.isNotEmpty(ftpFileArr); } @@ -439,7 +439,7 @@ public int stat(String path) { try { return this.client.stat(path); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -449,14 +449,14 @@ public boolean delFile(String path) { final String fileName = FileKit.getName(path); final String dir = StringKit.removeSuffix(path, fileName); if (false == cd(dir)) { - throw new InstrumentException("Change dir to [{}] error, maybe dir not exist!"); + throw new InternalException("Change dir to [{}] error, maybe dir not exist!"); } boolean isSuccess; try { isSuccess = client.deleteFile(fileName); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { cd(pwd); } @@ -469,7 +469,7 @@ public boolean delDir(String dirPath) { try { dirs = client.listFiles(dirPath); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } String name; String childPath; @@ -491,7 +491,7 @@ public boolean delDir(String dirPath) { try { return this.client.removeDirectory(dirPath); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -532,7 +532,7 @@ public boolean upload(String dest, String fileName, File file) { try (InputStream in = FileKit.getInputStream(file)) { return upload(dest, fileName, in); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -554,7 +554,7 @@ public boolean upload(String dest, String fileName, InputStream fileStream) { try { client.setFileType(FTPClient.BINARY_FILE_TYPE); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } String pwd = null; @@ -565,14 +565,14 @@ public boolean upload(String dest, String fileName, InputStream fileStream) { if (StringKit.isNotBlank(dest)) { mkDirs(dest); if (false == cd(dest)) { - throw new InstrumentException("Change dir to [{}] error, maybe dir not exist!"); + throw new InternalException("Change dir to [{}] error, maybe dir not exist!"); } } try { return client.storeFile(fileName, fileStream); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { if (this.backToPwd) { cd(pwd); @@ -610,7 +610,7 @@ public void download(String path, String fileName, File outFile) { try (OutputStream out = FileKit.getOutputStream(outFile)) { download(path, fileName, out); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -640,7 +640,7 @@ public void download(String path, String fileName, OutputStream out, java.nio.ch } if (false == cd(path)) { - throw new InstrumentException("Change dir to [{}] error, maybe dir not exist!"); + throw new InternalException("Change dir to [{}] error, maybe dir not exist!"); } if (null != charset) { @@ -650,7 +650,7 @@ public void download(String path, String fileName, OutputStream out, java.nio.ch client.setFileType(FTPClient.BINARY_FILE_TYPE); client.retrieveFile(fileName, out); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { if (backToPwd) { cd(pwd); diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/ftp/FtpServer.java b/bus-extra/src/main/java/org/aoju/bus/extra/ftp/FtpServer.java index 0c178e0404..086b650d5b 100644 --- a/bus-extra/src/main/java/org/aoju/bus/extra/ftp/FtpServer.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/ftp/FtpServer.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.extra.ftp; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.toolkit.NetKit; import org.apache.ftpserver.ConnectionConfig; @@ -144,7 +144,7 @@ public FtpServer addUser(User user) { try { getUserManager().save(user); } catch (org.apache.ftpserver.ftplet.FtpException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return this; } @@ -176,7 +176,7 @@ public FtpServer delUser(String userName) { try { getUserManager().delete(userName); } catch (org.apache.ftpserver.ftplet.FtpException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return this; } @@ -242,7 +242,7 @@ public void start() { try { serverFactory.createServer().start(); } catch (org.apache.ftpserver.ftplet.FtpException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/json/JsonFactory.java b/bus-extra/src/main/java/org/aoju/bus/extra/json/JsonFactory.java index 7f313b0ba6..f0f304016f 100644 --- a/bus-extra/src/main/java/org/aoju/bus/extra/json/JsonFactory.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/json/JsonFactory.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.extra.json; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.instance.Instances; import org.aoju.bus.core.toolkit.ClassKit; import org.aoju.bus.core.toolkit.StringKit; @@ -59,7 +59,7 @@ public static JsonProvider get() { public static JsonProvider create() { final JsonProvider engine = ClassKit.loadFirstAvailable(JsonProvider.class); if (null == engine) { - throw new InstrumentException("No json jar found ! Please add one of it to your project !"); + throw new InternalException("No json jar found ! Please add one of it to your project !"); } Logger.debug("Use [{}] provider as default.", StringKit.removeSuffix(engine.getClass().getSimpleName(), "Provider")); return engine; diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/json/provider/JacksonProvider.java b/bus-extra/src/main/java/org/aoju/bus/extra/json/provider/JacksonProvider.java index 4653d06f11..16470a903d 100644 --- a/bus-extra/src/main/java/org/aoju/bus/extra/json/provider/JacksonProvider.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/json/provider/JacksonProvider.java @@ -29,7 +29,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import java.io.IOException; import java.lang.reflect.Type; @@ -142,7 +142,7 @@ public T getValue(String json, String field) { try { return (T) objectMapper.readTree(json).get(field); } catch (JsonProcessingException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/PinyinFactory.java b/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/PinyinFactory.java index 976e078592..5a1f297da5 100644 --- a/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/PinyinFactory.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/PinyinFactory.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.extra.pinyin; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.instance.Instances; import org.aoju.bus.core.toolkit.ClassKit; import org.aoju.bus.core.toolkit.StringKit; @@ -58,7 +58,7 @@ public static PinyinProvider get() { public static PinyinProvider create() { final PinyinProvider engine = ClassKit.loadFirstAvailable(PinyinProvider.class); if (null == engine) { - throw new InstrumentException("No pinyin jar found ! Please add one of it to your project !"); + throw new InternalException("No pinyin jar found ! Please add one of it to your project !"); } Logger.debug("Use [{}] provider as default.", StringKit.removeSuffix(engine.getClass().getSimpleName(), "Provider")); return engine; diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/PinyinKit.java b/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/PinyinKit.java index 4c0dadf1e3..1e95f7f155 100644 --- a/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/PinyinKit.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/PinyinKit.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.extra.pinyin; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.lang.Normal; import org.aoju.bus.core.lang.RegEx; @@ -125,7 +125,7 @@ private static int getChsAscii(String chs) { asc = (Normal._256 * hightByte + lowByte) - Normal._256 * Normal._256; break; default: - throw new InstrumentException("Illegal resource string"); + throw new InternalException("Illegal resource string"); } return asc; } diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/provider/JPinyinProvider.java b/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/provider/JPinyinProvider.java index cde7190873..0e042e94d0 100644 --- a/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/provider/JPinyinProvider.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/provider/JPinyinProvider.java @@ -28,7 +28,7 @@ import com.github.stuxuhai.jpinyin.PinyinException; import com.github.stuxuhai.jpinyin.PinyinFormat; import com.github.stuxuhai.jpinyin.PinyinHelper; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.ArrayKit; /** @@ -71,7 +71,7 @@ public String getPinyin(String text, String separator) { try { return PinyinHelper.convertToPinyinString(text, separator, format); } catch (PinyinException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/provider/Pinyin4JProvider.java b/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/provider/Pinyin4JProvider.java index d5ea8ba93d..fa80cf0ce4 100644 --- a/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/provider/Pinyin4JProvider.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/pinyin/provider/Pinyin4JProvider.java @@ -31,7 +31,7 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.text.TextBuilder; import org.aoju.bus.core.toolkit.ArrayKit; @@ -114,7 +114,7 @@ public String getPinyin(String text, String separator) { } } } catch (BadHanyuPinyinOutputFormatCombination e) { - throw new InstrumentException(e); + throw new InternalException(e); } return result.toString(); } diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/qrcode/QrCodeKit.java b/bus-extra/src/main/java/org/aoju/bus/extra/qrcode/QrCodeKit.java index 65a8add4df..8a88d3974f 100755 --- a/bus-extra/src/main/java/org/aoju/bus/extra/qrcode/QrCodeKit.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/qrcode/QrCodeKit.java @@ -29,18 +29,22 @@ import com.google.zxing.common.BitMatrix; import com.google.zxing.common.GlobalHistogramBinarizer; import com.google.zxing.common.HybridBinarizer; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.codec.Base64; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.image.Images; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.lang.FileType; -import org.aoju.bus.core.toolkit.ImageKit; +import org.aoju.bus.core.lang.ansi.Ansi8BitColor; +import org.aoju.bus.core.lang.ansi.AnsiElement; +import org.aoju.bus.core.lang.ansi.AnsiEncoder; +import org.aoju.bus.core.toolkit.*; -import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; -import java.io.*; -import java.text.MessageFormat; -import java.util.Base64; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.InputStream; +import java.io.OutputStream; import java.util.HashMap; import java.util.Map; @@ -56,87 +60,6 @@ */ public class QrCodeKit { - /** - * 生成代 logo 图片的 Base64 编码格式的二维码,以 String 形式表示 - * - * @param content 内容 - * @param qrConfig 二维码配置,包括长、宽、边距、颜色等 - * @param imageType 图片类型(图片扩展名) - * @param logoBase64 logo 图片的 base64 编码 - * @return 图片 Base64 编码字符串 - */ - public static String generate(String content, QrConfig qrConfig, String imageType, String logoBase64) { - byte[] decode; - try { - decode = Base64.getDecoder().decode(logoBase64); - } catch (Exception e) { - throw new InstrumentException(e); - } - return generate(content, qrConfig, imageType, decode); - } - - /** - * 生成代 logo 图片的 Base64 编码格式的二维码,以 String 形式表示 - * - * @param content 内容 - * @param qrConfig 二维码配置,包括长、宽、边距、颜色等 - * @param imageType 图片类型(图片扩展名) - * @param logo logo 图片的byte[] - * @return 图片 Base64 编码字符串 - */ - public static String generate(String content, QrConfig qrConfig, String imageType, byte[] logo) { - BufferedImage img; - try { - img = ImageIO.read(new ByteArrayInputStream(logo)); - } catch (IOException e) { - throw new InstrumentException(e); - } - qrConfig.setImg(img); - return generate(content, qrConfig, imageType); - } - - /** - * 生成 Base64 编码格式的二维码,以 String 形式表示 - * - * @param content 内容 - * @param qrConfig 二维码配置,包括长、宽、边距、颜色等 - * @param imageType 图片类型(图片扩展名) - * @return 图片 Base64 编码字符串 - */ - public static String generate(String content, QrConfig qrConfig, String imageType) { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - generate(content, qrConfig, imageType, bos); - byte[] encode = Base64.getEncoder().encode(bos.toByteArray()); - return MessageFormat.format("data:image/{0};base64,{1}", imageType, new String(encode)); - } - - /** - * 生成PNG格式的二维码图片,以byte[]形式表示 - * - * @param content 内容 - * @param width 宽度 - * @param height 高度 - * @return 图片的byte[] - */ - public static byte[] generatePng(String content, int width, int height) { - final ByteArrayOutputStream out = new ByteArrayOutputStream(); - generate(content, width, height, FileType.TYPE_PNG, out); - return out.toByteArray(); - } - - /** - * 生成PNG格式的二维码图片,以byte[]形式表示 - * - * @param content 内容 - * @param config 二维码配置,包括长、宽、边距、颜色等 - * @return 图片的byte[] - */ - public static byte[] generatePng(String content, QrConfig config) { - final ByteArrayOutputStream out = new ByteArrayOutputStream(); - generate(content, config, FileType.TYPE_PNG, out); - return out.toByteArray(); - } - /** * 生成二维码到文件,二维码图片格式取决于文件的扩展名 * @@ -147,8 +70,22 @@ public static byte[] generatePng(String content, QrConfig config) { * @return 目标文件 */ public static File generate(String content, int width, int height, File targetFile) { - final BufferedImage image = generate(content, width, height); - ImageKit.write(image, targetFile); + String extName = FileKit.getSuffix(targetFile); + switch (extName) { + case FileType.TYPE_SVG: + String svg = generateAsSvg(content, new QrConfig(width, height)); + FileKit.writeString(svg, targetFile, Charset.UTF_8); + break; + case FileType.TYPE_TXT: + String txt = generateAsAsciiArt(content, new QrConfig(width, height)); + FileKit.writeString(txt, targetFile, Charset.UTF_8); + break; + default: + final BufferedImage image = generate(content, width, height); + ImageKit.write(image, targetFile); + break; + } + return targetFile; } @@ -161,8 +98,21 @@ public static File generate(String content, int width, int height, File targetFi * @return 目标文件 */ public static File generate(String content, QrConfig config, File targetFile) { - final BufferedImage image = generate(content, config); - ImageKit.write(image, targetFile); + String extName = FileKit.getSuffix(targetFile); + switch (extName) { + case FileType.TYPE_SVG: + final String svg = generateAsSvg(content, config); + FileKit.writeString(svg, targetFile, Charset.UTF_8); + break; + case FileType.TYPE_TXT: + final String txt = generateAsAsciiArt(content, config); + FileKit.writeString(txt, targetFile, Charset.UTF_8); + break; + default: + final BufferedImage image = generate(content, config); + ImageKit.write(image, targetFile); + break; + } return targetFile; } @@ -176,21 +126,45 @@ public static File generate(String content, QrConfig config, File targetFile) { * @param out 目标流 */ public static void generate(String content, int width, int height, String imageType, OutputStream out) { - final BufferedImage image = generate(content, width, height); - ImageKit.write(image, imageType, out); + switch (imageType) { + case FileType.TYPE_SVG: + final String svg = generateAsSvg(content, new QrConfig(width, height)); + IoKit.writeUtf8(out, false, svg); + break; + case FileType.TYPE_TXT: + final String txt = generateAsAsciiArt(content, new QrConfig(width, height)); + IoKit.writeUtf8(out, false, txt); + break; + default: + final BufferedImage image = generate(content, width, height); + ImageKit.write(image, imageType, out); + break; + } } /** * 生成二维码到输出流 * * @param content 文本内容 - * @param config 二维码配置,包括长、宽、边距、颜色等 - * @param imageType 图片类型(图片扩展名),见{@link ImageKit} + * @param config 二维码配置,包括长、宽、边距、颜色等 + * @param imageType 类型(图片扩展名) * @param out 目标流 */ public static void generate(String content, QrConfig config, String imageType, OutputStream out) { - final BufferedImage image = generate(content, config); - ImageKit.write(image, imageType, out); + switch (imageType) { + case FileType.TYPE_SVG: + final String svg = generateAsSvg(content, config); + IoKit.writeUtf8(out, false, svg); + break; + case FileType.TYPE_TXT: + final String txt = generateAsAsciiArt(content, config); + IoKit.writeUtf8(out, false, txt); + break; + default: + final BufferedImage image = generate(content, config); + ImageKit.write(image, imageType, out); + break; + } } /** @@ -266,6 +240,148 @@ public static BufferedImage generate(String content, BarcodeFormat format, QrCon return image; } + + /** + * 生成代 logo 图片的 Base64 编码格式的二维码,以 String 形式表示 + * + * @param content 内容 + * @param qrConfig 二维码配置,包括长、宽、边距、颜色等 + * @param imageType 图片类型(图片扩展名) + * @param logoBase64 logo 图片的 base64 编码 + * @return 图片 Base64 编码字符串 + */ + public static String generateAsBase64(String content, QrConfig qrConfig, String imageType, String logoBase64) { + return generateAsBase64(content, qrConfig, imageType, Base64.decode(logoBase64)); + } + + /** + * 生成代 logo 图片的 Base64 编码格式的二维码,以 String 形式表示 + * + * @param content 内容 + * @param qrConfig 二维码配置,包括长、宽、边距、颜色等 + * @param imageType 类型(图片扩展名) + * @param logo logo 图片的byte[] + * @return 图片 Base64 编码字符串 + */ + public static String generateAsBase64(String content, QrConfig qrConfig, String imageType, byte[] logo) { + return generateAsBase64(content, qrConfig, imageType, ImageKit.toImage(logo)); + } + + /** + * 生成代 logo 图片的 Base64 编码格式的二维码,以 String 形式表示 + * + * @param content 内容 + * @param qrConfig 二维码配置,包括长、宽、边距、颜色等 + * @param imageType 类型(图片扩展名) + * @param logo logo 图片的byte[] + * @return 图片 Base64 编码字符串 + */ + public static String generateAsBase64(String content, QrConfig qrConfig, String imageType, Image logo) { + qrConfig.setImg(logo); + return generateAsBase64(content, qrConfig, imageType); + } + + /** + * 生成 Base64 编码格式的二维码,以 String 形式表示 + * + *

+ * 输出格式为: data:image/[type];base64,[data] + *

+ * + * @param content 内容 + * @param qrConfig 二维码配置,包括长、宽、边距、颜色等 + * @param imageType 类型(图片扩展名) + * @return 图片 Base64 编码字符串 + */ + public static String generateAsBase64(String content, QrConfig qrConfig, String imageType) { + String result; + switch (imageType) { + case FileType.TYPE_SVG: + String svg = generateAsSvg(content, qrConfig); + result = UriKit.toURL("image/svg+xml", "base64", Base64.encode(svg)); + break; + case FileType.TYPE_TXT: + String txt = generateAsAsciiArt(content, qrConfig); + result = UriKit.toURL("text/plain", "base64", Base64.encode(txt)); + break; + default: + final BufferedImage img = generate(content, qrConfig); + result = ImageKit.toBase64Uri(img, imageType); + break; + } + + + return result; + } + + /** + * 生成PNG格式的二维码图片,以byte[]形式表示 + * + * @param content 内容 + * @param width 宽度 + * @param height 高度 + * @return 图片的byte[] + */ + public static byte[] generatePng(String content, int width, int height) { + final ByteArrayOutputStream out = new ByteArrayOutputStream(); + generate(content, width, height, FileType.TYPE_PNG, out); + return out.toByteArray(); + } + + /** + * 生成PNG格式的二维码图片,以byte[]形式表示 + * + * @param content 内容 + * @param config 二维码配置,包括长、宽、边距、颜色等 + * @return 图片的byte[] + */ + public static byte[] generatePng(String content, QrConfig config) { + final ByteArrayOutputStream out = new ByteArrayOutputStream(); + generate(content, config, FileType.TYPE_PNG, out); + return out.toByteArray(); + } + + /** + * @param content 内容 + * @param qrConfig 二维码配置,包括长、宽、边距、颜色等 + * @return SVG矢量图(字符串) + */ + public static String generateAsSvg(String content, QrConfig qrConfig) { + return toSVG(encode(content, qrConfig), qrConfig.foreColor, qrConfig.backColor, qrConfig.img, qrConfig.getRatio()); + } + + /** + * 生成ASCII Art字符画形式的二维码 + * + * @param content 内容 + * @return ASCII Art字符画形式的二维码字符串 + */ + public static String generateAsAsciiArt(String content) { + return generateAsAsciiArt(content, 0, 0, 1); + } + + /** + * 生成ASCII Art字符画形式的二维码 + * + * @param content 内容 + * @param qrConfig 二维码配置,仅长、宽、边距配置有效 + * @return ASCII Art字符画形式的二维码 + */ + public static String generateAsAsciiArt(String content, QrConfig qrConfig) { + return toAsciiArt(encode(content, qrConfig), qrConfig); + } + + /** + * @param content 内容 + * @param width 宽 + * @param height 长 + * @return ASCII Art字符画形式的二维码 + */ + public static String generateAsAsciiArt(String content, int width, int height, int margin) { + QrConfig qrConfig = new QrConfig(width, height).setMargin(margin); + return generateAsAsciiArt(content, qrConfig); + } + /** * 将文本内容编码为二维码 * @@ -320,7 +436,7 @@ public static BitMatrix encode(String content, BarcodeFormat format, QrConfig co try { bitMatrix = multiFormatWriter.encode(content, format, config.width, config.height, config.toHints(format)); } catch (WriterException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return bitMatrix; @@ -337,7 +453,7 @@ public static String decode(InputStream qrCodeInputstream) { } /** - * 将二维码或条形码图片解码为文本 + * 解码二维码或条形码图片为文本 * * @param qrCodeFile 二维码文件 * @return 解码文本 @@ -417,6 +533,123 @@ public static BufferedImage toImage(BitMatrix matrix, int foreColor, Integer bac return image; } + /** + * BitMatrix转SVG(字符串) + * + * @param matrix 二维的位矩阵 + * @param foreColor 前景色 + * @param backColor 背景色(null表示透明背景) + * @param ratio 二维码中的Logo缩放的比例系数,如5表示长宽最小值的1/5 + * @return SVG矢量图(字符串) + */ + public static String toSVG(BitMatrix matrix, int foreColor, Integer backColor, Image logoImg, int ratio) { + StringBuilder sb = new StringBuilder(); + int qrWidth = matrix.getWidth(); + int qrHeight = matrix.getHeight(); + int moduleHeight = (qrHeight == 1) ? qrWidth / 2 : 1; + for (int y = 0; y < qrHeight; y++) { + for (int x = 0; x < qrWidth; x++) { + if (matrix.get(x, y)) { + sb.append(" M" + x + "," + y + "h1v" + moduleHeight + "h-1z"); + } + } + } + qrHeight *= moduleHeight; + String logoBase64 = ""; + int logoWidth = 0; + int logoHeight = 0; + int logoX = 0; + int logoY = 0; + if (logoImg != null) { + logoBase64 = ImageKit.toBase64Uri(logoImg, "png"); + // 按照最短的边做比例缩放 + if (qrWidth < qrHeight) { + logoWidth = qrWidth / ratio; + logoHeight = logoImg.getHeight(null) * logoWidth / logoImg.getWidth(null); + } else { + logoHeight = qrHeight / ratio; + logoWidth = logoImg.getWidth(null) * logoHeight / logoImg.getHeight(null); + } + logoX = (qrWidth - logoWidth) / 2; + logoY = (qrHeight - logoHeight) / 2; + + } + + Color fore = new Color(foreColor, true); + + StringBuilder result = StringKit.builder(); + result.append("\n"); + result.append(" \n"); + if (StringKit.isNotBlank(logoBase64)) { + result.append("\n"); + } + result.append(""); + return result.toString(); + } + + /** + * BitMatrix转ASCII Art字符画形式的二维码 + * + * @param bitMatrix + * @return ASCII Art字符画形式的二维码 + */ + public static String toAsciiArt(BitMatrix bitMatrix, QrConfig qrConfig) { + final int width = bitMatrix.getWidth(); + final int height = bitMatrix.getHeight(); + + + final AnsiElement foreground = qrConfig.foreColor == null ? null : Ansi8BitColor.foreground(rgbToAnsi8BitValue(qrConfig.foreColor)); + final AnsiElement background = qrConfig.backColor == null ? null : Ansi8BitColor.background(rgbToAnsi8BitValue(qrConfig.backColor)); + + StringBuilder builder = new StringBuilder(); + for (int i = 0; i <= height; i += 2) { + StringBuilder rowBuilder = new StringBuilder(); + for (int j = 0; j < width; j++) { + boolean tp = bitMatrix.get(i, j); + boolean bt = i + 1 >= height || bitMatrix.get(i + 1, j); + if (tp && bt) { + rowBuilder.append(' ');//'\u0020' + } else if (tp) { + rowBuilder.append('▄');//'\u2584' + } else if (bt) { + rowBuilder.append('▀');//'\u2580' + } else { + rowBuilder.append('█');//'\u2588' + } + } + builder.append(AnsiEncoder.encode(foreground, background, rowBuilder)).append('\n'); + } + return builder.toString(); + } + + /** + * rgb转Ansi8Bit值 + * + * @param rgb rgb颜色值 + * @return Ansi8bit颜色值 + */ + private static int rgbToAnsi8BitValue(int rgb) { + final int r = (rgb >> 16) & 0xff; + final int g = (rgb >> 8) & 0xff; + final int b = (rgb) & 0xff; + + final int l; + if (r == g && g == b) { + final int i = (int) (MathKit.div(MathKit.mul(r - 10.625, 23), (255 - 10.625), 0)); + l = i >= 0 ? 232 + i : 0; + } else { + l = 16 + (int) (36 * MathKit.div(MathKit.mul(r, 5), 255, 0)) + (int) (6.0 * (g / 256.0 * 6.0)) + (int) (b / 256.0 * 6.0); + } + return l; + } + /** * 创建解码选项 diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/qrcode/QrConfig.java b/bus-extra/src/main/java/org/aoju/bus/extra/qrcode/QrConfig.java index 3ab6f37edf..5d459ca660 100755 --- a/bus-extra/src/main/java/org/aoju/bus/extra/qrcode/QrConfig.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/qrcode/QrConfig.java @@ -46,6 +46,7 @@ */ public class QrConfig { + private static final int BLACK = 0xFF000000; private static final int WHITE = 0xFFFFFFFF; @@ -60,9 +61,9 @@ public class QrConfig { /** * 前景色(二维码颜色) */ - public int foreColor = BLACK; + public Integer foreColor = BLACK; /** - * 背景色 + * 背景色,默认白色,null表示透明 */ public Integer backColor = WHITE; /** @@ -178,7 +179,9 @@ public int getForeColor() { * @return this */ public QrConfig setForeColor(Color foreColor) { - if (null != foreColor) { + if (null == foreColor) { + this.foreColor = null; + } else { this.foreColor = foreColor.getRGB(); } return this; @@ -383,7 +386,6 @@ public HashMap toHints(BarcodeFormat format) { if (null != this.errorCorrection) { Object value; if (BarcodeFormat.AZTEC == format || BarcodeFormat.PDF_417 == format) { - // issue#I4FE3U@Gitee value = this.errorCorrection.getBits(); } else { value = this.errorCorrection; diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/servlet/ServletKit.java b/bus-extra/src/main/java/org/aoju/bus/extra/servlet/ServletKit.java index 91b1783309..7dd041493a 100644 --- a/bus-extra/src/main/java/org/aoju/bus/extra/servlet/ServletKit.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/servlet/ServletKit.java @@ -28,7 +28,7 @@ import org.aoju.bus.core.beans.copier.CopyOptions; import org.aoju.bus.core.beans.copier.ValueProvider; import org.aoju.bus.core.collection.ArrayIterator; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.*; import org.aoju.bus.core.map.CaseInsensitiveMap; import org.aoju.bus.core.toolkit.*; @@ -86,7 +86,7 @@ public static String getBody(ServletRequest request) { try (final BufferedReader reader = request.getReader()) { return IoKit.read(reader); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -101,7 +101,7 @@ public static byte[] getBodyBytes(ServletRequest request) { try { return IoKit.readBytes(request.getInputStream()); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -454,13 +454,13 @@ public static void addCookie(HttpServletResponse response, String name, String v * * @param response 响应对象{@link HttpServletResponse} * @return 获得PrintWriter - * @throws InstrumentException IO异常 + * @throws InternalException IO异常 */ - public static PrintWriter getWriter(HttpServletResponse response) throws InstrumentException { + public static PrintWriter getWriter(HttpServletResponse response) throws InternalException { try { return response.getWriter(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -479,7 +479,7 @@ public static void write(HttpServletResponse response, String text, String conte writer.write(text); writer.flush(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(writer); } @@ -553,7 +553,7 @@ public static void write(HttpServletResponse response, InputStream in, int buffe out = response.getOutputStream(); IoKit.copy(in, out, bufferSize); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(out); IoKit.close(in); diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/ssh/JSchKit.java b/bus-extra/src/main/java/org/aoju/bus/extra/ssh/JSchKit.java index db6bd7a01e..9d46c4d6fb 100755 --- a/bus-extra/src/main/java/org/aoju/bus/extra/ssh/JSchKit.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/ssh/JSchKit.java @@ -26,7 +26,7 @@ package org.aoju.bus.extra.ssh; import com.jcraft.jsch.*; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Assert; import org.aoju.bus.core.lang.Charset; import org.aoju.bus.core.toolkit.IoKit; @@ -125,7 +125,7 @@ public static Session openSession(String sshHost, int sshPort, String sshUser, S try { session.connect(timeout); } catch (JSchException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return session; } @@ -160,7 +160,7 @@ public static Session openSession(String sshHost, int sshPort, String sshUser, S try { session.connect(timeOut); } catch (JSchException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return session; } @@ -202,7 +202,7 @@ public static Session createSession(String sshHost, int sshPort, String sshUser, try { jsch.addIdentity(privateKeyPath, passphrase); } catch (JSchException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return createSession(jsch, sshHost, sshPort, sshUser); @@ -234,7 +234,7 @@ public static Session createSession(JSch jsch, String sshHost, int sshPort, Stri try { session = jsch.getSession(sshUser, sshHost, sshPort); } catch (JSchException e) { - throw new InstrumentException(e); + throw new InternalException(e); } // 设置第一次登录的时候提示,可选值:(ask | yes | no) @@ -251,9 +251,9 @@ public static Session createSession(JSch jsch, String sshHost, int sshPort, Stri * @param remotePort 远程端口 * @param localPort 本地端口 * @return 成功与否 - * @throws InstrumentException 端口绑定失败异常 + * @throws InternalException 端口绑定失败异常 */ - public static boolean bindPort(Session session, String remoteHost, int remotePort, int localPort) throws InstrumentException { + public static boolean bindPort(Session session, String remoteHost, int remotePort, int localPort) throws InternalException { return bindPort(session, remoteHost, remotePort, "127.0.0.1", localPort); } @@ -266,14 +266,14 @@ public static boolean bindPort(Session session, String remoteHost, int remotePor * @param localHost 本地主机 * @param localPort 本地端口 * @return 成功与否 - * @throws InstrumentException 端口绑定失败异常 + * @throws InternalException 端口绑定失败异常 */ - public static boolean bindPort(Session session, String remoteHost, int remotePort, String localHost, int localPort) throws InstrumentException { + public static boolean bindPort(Session session, String remoteHost, int remotePort, String localHost, int localPort) throws InternalException { if (session != null && session.isConnected()) { try { session.setPortForwardingL(localHost, localPort, remoteHost, remotePort); } catch (JSchException e) { - throw new InstrumentException("From [{}:{}] mapping to [{}:{}] error !", remoteHost, remotePort, localHost, localPort); + throw new InternalException("From [{}:{}] mapping to [{}:{}] error !", remoteHost, remotePort, localHost, localPort); } return true; } @@ -288,14 +288,14 @@ public static boolean bindPort(Session session, String remoteHost, int remotePor * @param host 转发到的host * @param port host上的端口 * @return 成功与否 - * @throws InstrumentException 端口绑定失败异常 + * @throws InternalException 端口绑定失败异常 */ - public static boolean bindPort(Session session, int bindPort, String host, int port) throws InstrumentException { + public static boolean bindPort(Session session, int bindPort, String host, int port) throws InternalException { if (null != session && session.isConnected()) { try { session.setPortForwardingR(bindPort, host, port); } catch (JSchException e) { - throw new InstrumentException("From [{}] mapping to [{}] error!", bindPort, port); + throw new InternalException("From [{}] mapping to [{}] error!", bindPort, port); } return true; } @@ -314,7 +314,7 @@ public static boolean unBindPort(Session session, int localPort) { session.delPortForwardingL(localPort); return true; } catch (JSchException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -325,12 +325,12 @@ public static boolean unBindPort(Session session, int localPort) { * @param remoteHost 远程主机 * @param remotePort 远程端口 * @return 映射后的本地端口 - * @throws InstrumentException 连接异常 + * @throws InternalException 连接异常 */ - public static int openAndBindPortToLocal(Connector sshConn, String remoteHost, int remotePort) throws InstrumentException { + public static int openAndBindPortToLocal(Connector sshConn, String remoteHost, int remotePort) throws InternalException { final Session session = openSession(sshConn.getHost(), sshConn.getPort(), sshConn.getUser(), sshConn.getPassword()); if (null == session) { - throw new InstrumentException("Error to create SSH Session!"); + throw new InternalException("Error to create SSH Session!"); } final int localPort = generateLocalPort(); bindPort(session, remoteHost, remotePort, localPort); @@ -380,7 +380,7 @@ public static Channel openChannel(Session session, ChannelType channelType) { try { channel.connect(); } catch (JSchException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return channel; } @@ -398,7 +398,7 @@ public static Channel openChannel(Session session, ChannelType channelType, int try { channel.connect(Math.max(timeout, 0)); } catch (JSchException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return channel; } @@ -441,7 +441,7 @@ public static Channel createChannel(Session session, ChannelType channelType) { } channel = session.openChannel(channelType.getValue()); } catch (JSchException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return channel; } @@ -482,9 +482,9 @@ public static String exec(Session session, String cmd, java.nio.charset.Charset in = channel.getInputStream(); return IoKit.read(in, charset); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } catch (JSchException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(in); close(channel); @@ -514,7 +514,7 @@ public static String execByShell(Session session, String cmd, java.nio.charset.C return IoKit.read(in, charset); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(out); IoKit.close(in); diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/ssh/Sftp.java b/bus-extra/src/main/java/org/aoju/bus/extra/ssh/Sftp.java index 1f10223b91..2b9d05b524 100755 --- a/bus-extra/src/main/java/org/aoju/bus/extra/ssh/Sftp.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/ssh/Sftp.java @@ -28,7 +28,7 @@ import com.jcraft.jsch.*; import com.jcraft.jsch.ChannelSftp.LsEntry; import com.jcraft.jsch.ChannelSftp.LsEntrySelector; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Filter; import org.aoju.bus.core.lang.Symbol; import org.aoju.bus.core.toolkit.FileKit; @@ -191,7 +191,7 @@ public void init(ChannelSftp channel, Charset charset) { try { channel.setFilenameEncoding(charset.toString()); } catch (SftpException e) { - throw new InstrumentException(e); + throw new InternalException(e); } this.channel = channel; } @@ -199,11 +199,11 @@ public void init(ChannelSftp channel, Charset charset) { @Override public Sftp reconnectIfTimeout() { if (StringKit.isBlank(this.ftpConfig.getHost())) { - throw new InstrumentException("Host is blank!"); + throw new InternalException("Host is blank!"); } try { this.cd(Symbol.SLASH); - } catch (InstrumentException e) { + } catch (InternalException e) { close(); init(); } @@ -229,7 +229,7 @@ public String pwd() { try { return channel.pwd(); } catch (SftpException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -242,7 +242,7 @@ public String home() { try { return channel.getHome(); } catch (SftpException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -299,7 +299,7 @@ public List ls(String path, final Filter filter) { }); } catch (SftpException e) { if (false == StringKit.startWithIgnoreCase(e.getMessage(), "No such file")) { - throw new InstrumentException(e); + throw new InternalException(e); } } return fileNames; @@ -315,7 +315,7 @@ public boolean mkdir(String dir) { this.channel.mkdir(dir); return true; } catch (SftpException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -329,7 +329,7 @@ public boolean isDir(String dir) { if (StringKit.containsAnyIgnoreCase(msg, "No such file", "does not exist")) { return false; } - throw new InstrumentException(e); + throw new InternalException(e); } return sftpATTRS.isDir(); } @@ -350,7 +350,7 @@ public synchronized boolean cd(String directory) { channel.cd(directory.replace(Symbol.C_BACKSLASH, Symbol.C_SLASH)); return true; } catch (SftpException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -364,7 +364,7 @@ public boolean delFile(String filePath) { try { channel.rm(filePath); } catch (SftpException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return true; } @@ -385,7 +385,7 @@ public boolean delDir(String dirPath) { try { list = channel.ls(channel.pwd()); } catch (SftpException e) { - throw new InstrumentException(e); + throw new InternalException(e); } String fileName; @@ -410,7 +410,7 @@ public boolean delDir(String dirPath) { channel.rmdir(dirPath); return true; } catch (SftpException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -485,7 +485,7 @@ public Sftp put(String srcFilePath, String destPath, SftpProgressMonitor monitor try { channel.put(srcFilePath, destPath, monitor, mode.ordinal()); } catch (SftpException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return this; } @@ -503,7 +503,7 @@ public Sftp put(InputStream srcStream, String destPath, SftpProgressMonitor moni try { channel.put(srcStream, destPath, monitor, mode.ordinal()); } catch (SftpException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return this; } @@ -583,7 +583,7 @@ public Sftp get(String src, String dest) { try { channel.get(src, dest); } catch (SftpException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return this; } @@ -599,7 +599,7 @@ public Sftp get(String src, OutputStream out) { try { channel.get(src, out); } catch (SftpException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return this; } diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/ssh/SshjSftp.java b/bus-extra/src/main/java/org/aoju/bus/extra/ssh/SshjSftp.java index d05c0039e3..c283ca5f6d 100644 --- a/bus-extra/src/main/java/org/aoju/bus/extra/ssh/SshjSftp.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/ssh/SshjSftp.java @@ -31,7 +31,7 @@ import net.schmizz.sshj.sftp.SFTPClient; import net.schmizz.sshj.transport.verification.PromiscuousVerifier; import net.schmizz.sshj.xfer.FileSystemFile; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Symbol; import org.aoju.bus.core.toolkit.CollKit; import org.aoju.bus.core.toolkit.FileKit; @@ -129,18 +129,18 @@ public void init() { ssh.setRemoteCharset(ftpConfig.getCharset()); this.sftp = ssh.newSFTPClient(); } catch (IOException e) { - throw new InstrumentException("sftp 初始化失败", e); + throw new InternalException("sftp 初始化失败", e); } } @Override public AbstractFtp reconnectIfTimeout() { if (StringKit.isBlank(this.ftpConfig.getHost())) { - throw new InstrumentException("Host is blank!"); + throw new InternalException("Host is blank!"); } try { this.cd(Symbol.SLASH); - } catch (InstrumentException e) { + } catch (InternalException e) { close(); init(); } @@ -165,7 +165,7 @@ public boolean mkdir(String dir) { try { sftp.mkdir(dir); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } return containsFile(dir); } @@ -176,7 +176,7 @@ public List ls(String path) { try { infoList = sftp.ls(path); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } if (CollKit.isNotEmpty(infoList)) { return CollKit.map(infoList, RemoteResourceInfo::getName, true); @@ -190,7 +190,7 @@ public boolean delFile(String path) { sftp.rm(path); return !containsFile(path); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -200,7 +200,7 @@ public boolean delDir(String dirPath) { sftp.rmdir(dirPath); return !containsFile(dirPath); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -210,7 +210,7 @@ public boolean upload(String destPath, File file) { sftp.put(new FileSystemFile(file), destPath); return containsFile(destPath); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -219,7 +219,7 @@ public void download(String path, File dest) { try { sftp.get(path, new FileSystemFile(dest)); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -237,7 +237,7 @@ public void close() { sftp.close(); ssh.disconnect(); } catch (IOException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } @@ -270,7 +270,7 @@ public String command(String exec) { InputStream inputStream = command.getInputStream(); return IoKit.read(inputStream, DEFAULT_CHARSET); } catch (Exception e) { - throw new InstrumentException(e); + throw new InternalException(e); } finally { IoKit.close(session); } diff --git a/bus-gitlab/README.md b/bus-gitlab/README.md index 37a7c9798a..3419393762 100755 --- a/bus-gitlab/README.md +++ b/bus-gitlab/README.md @@ -70,7 +70,7 @@ dependencies { org.aoju bus-gitlab - 6.5.6 + 6.5.8 ``` diff --git a/bus-gitlab/pom.xml b/bus-gitlab/pom.xml index d375a4ad68..f78c3a2c49 100755 --- a/bus-gitlab/pom.xml +++ b/bus-gitlab/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-gitlab - 6.5.6 + 6.5.8 jar ${project.artifactId} diff --git a/bus-goalie/pom.xml b/bus-goalie/pom.xml index 6e785b5b92..caba9948b4 100644 --- a/bus-goalie/pom.xml +++ b/bus-goalie/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-goalie - 6.5.6 + 6.5.8 jar ${project.artifactId} @@ -42,7 +42,7 @@ UTF-8 UTF-8 17 - 2.7.2 + 2.7.3 1.18.24 31.1-jre diff --git a/bus-health/pom.xml b/bus-health/pom.xml index 3972c86f53..fc6e2eb072 100755 --- a/bus-health/pom.xml +++ b/bus-health/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-health - 6.5.6 + 6.5.8 jar ${project.artifactId} diff --git a/bus-health/src/main/java/org/aoju/bus/health/Platform.java b/bus-health/src/main/java/org/aoju/bus/health/Platform.java index 20c2aac709..05ad6842e6 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/Platform.java +++ b/bus-health/src/main/java/org/aoju/bus/health/Platform.java @@ -26,7 +26,7 @@ package org.aoju.bus.health; import org.aoju.bus.core.convert.Convert; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Normal; import org.aoju.bus.core.lang.Symbol; import org.aoju.bus.core.toolkit.StringKit; @@ -255,7 +255,7 @@ public static String get(String name, boolean quiet) { try { return System.getProperty(name); } catch (SecurityException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-http/pom.xml b/bus-http/pom.xml index 15f34056c0..b14f44ddb4 100755 --- a/bus-http/pom.xml +++ b/bus-http/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-http - 6.5.6 + 6.5.8 jar ${project.artifactId} diff --git a/bus-http/src/main/java/org/aoju/bus/http/Httpv.java b/bus-http/src/main/java/org/aoju/bus/http/Httpv.java index bc14585d2a..523738388d 100644 --- a/bus-http/src/main/java/org/aoju/bus/http/Httpv.java +++ b/bus-http/src/main/java/org/aoju/bus/http/Httpv.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.http; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Header; import org.aoju.bus.core.lang.Http; import org.aoju.bus.core.lang.MediaType; @@ -246,7 +246,7 @@ private String urlPath(String urlPath, boolean websocket) { if (null != baseUrl) { fullUrl = baseUrl; } else { - throw new InstrumentException("Before setting BaseUrl, you must specify a specific path to initiate a request!"); + throw new InternalException("Before setting BaseUrl, you must specify a specific path to initiate a request!"); } } else { boolean isFullPath = urlPath.startsWith(Http.HTTPS_PREFIX) @@ -258,7 +258,7 @@ private String urlPath(String urlPath, boolean websocket) { } else if (null != baseUrl) { fullUrl = baseUrl + urlPath; } else { - throw new InstrumentException("Before setting BaseUrl, you must use the full path URL to initiate the request. The current URL is:" + urlPath); + throw new InternalException("Before setting BaseUrl, you must use the full path URL to initiate the request. The current URL is:" + urlPath); } } if (websocket && fullUrl.startsWith(Http.HTTP)) { diff --git a/bus-http/src/main/java/org/aoju/bus/http/Httpx.java b/bus-http/src/main/java/org/aoju/bus/http/Httpx.java index 7c514a3b43..fec8089aef 100755 --- a/bus-http/src/main/java/org/aoju/bus/http/Httpx.java +++ b/bus-http/src/main/java/org/aoju/bus/http/Httpx.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.http; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.*; import org.aoju.bus.core.toolkit.ArrayKit; import org.aoju.bus.core.toolkit.MapKit; @@ -537,7 +537,7 @@ private static Request.Builder builder(final Builder builder) { request.method(method, form.build()); } } else { - throw new InstrumentException(String.format(">>>>>>>>Request Method Not found[%s]<<<<<<<<", method)); + throw new InternalException(String.format(">>>>>>>>Request Method Not found[%s]<<<<<<<<", method)); } return request; } diff --git a/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/CoverCall.java b/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/CoverCall.java index 3fe2a776e4..a18086b75b 100644 --- a/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/CoverCall.java +++ b/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/CoverCall.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.http.plugin.httpv; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.ByteString; import org.aoju.bus.core.lang.Http; import org.aoju.bus.http.Httpv; @@ -293,7 +293,7 @@ public void onFailure(WebSocket webSocket, Throwable t, Response response) { } else if (null != client.onException) { client.execute(() -> client.onException.on(this.webSocket, t), client.exceptionOnIO); } else if (!client.nothrow) { - throw new InstrumentException("WebSocket exception", t); + throw new InternalException("WebSocket exception", t); } } diff --git a/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/CoverHttp.java b/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/CoverHttp.java index 4ad14164c3..207fb3f2be 100644 --- a/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/CoverHttp.java +++ b/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/CoverHttp.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.http.plugin.httpv; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Http; import org.aoju.bus.core.lang.MediaType; import org.aoju.bus.core.lang.Symbol; @@ -572,7 +572,7 @@ private long contentLength(RequestBody reqBody) { try { return reqBody.length(); } catch (IOException e) { - throw new InstrumentException("Cannot get the length of the request body", e); + throw new InternalException("Cannot get the length of the request body", e); } } @@ -655,7 +655,7 @@ private RequestBody toRequestBody(Object object) { private String buildUrlPath() { String url = urlPath; if (null == url || url.trim().isEmpty()) { - throw new InstrumentException("Url cannot be empty!"); + throw new InternalException("Url cannot be empty!"); } if (null != pathParams) { for (String name : pathParams.keySet()) { @@ -663,12 +663,12 @@ private String buildUrlPath() { if (url.contains(target)) { url = url.replace(target, pathParams.get(name)); } else { - throw new InstrumentException("pathParameter [ " + name + " ] Does not exist in url [ " + urlPath + " ]"); + throw new InternalException("pathParameter [ " + name + " ] Does not exist in url [ " + urlPath + " ]"); } } } if (url.matches(PATH_PARAM_REGEX)) { - throw new InstrumentException("There is no setting for pathParameter in url, you must first call addPathParam to set it!"); + throw new InternalException("There is no setting for pathParameter in url, you must first call addPathParam to set it!"); } if (null != urlParams) { url = buildUrl(url.trim()); @@ -681,7 +681,7 @@ private String buildUrl(String url) { if (url.contains(Symbol.QUESTION_MARK)) { if (!url.endsWith(Symbol.QUESTION_MARK)) { if (url.lastIndexOf(Symbol.EQUAL) < url.lastIndexOf(Symbol.QUESTION_MARK) + 2) { - throw new InstrumentException("URL format error,'?' Not found after '='"); + throw new InternalException("URL format error,'?' Not found after '='"); } if (!url.endsWith(Symbol.AND)) { sb.append(Symbol.C_AND); @@ -700,21 +700,21 @@ private String buildUrl(String url) { protected void assertNotConflict(boolean bodyCantUsed) { if (bodyCantUsed) { if (ObjectKit.isNotEmpty(requestBody)) { - throw new InstrumentException("GET | HEAD request The setBodyPara method cannot be called!"); + throw new InternalException("GET | HEAD request The setBodyPara method cannot be called!"); } if (MapKit.isNotEmpty(bodyParams)) { - throw new InstrumentException("GET | HEAD request The addBodyPara method cannot be called!"); + throw new InternalException("GET | HEAD request The addBodyPara method cannot be called!"); } if (MapKit.isNotEmpty(files)) { - throw new InstrumentException("GET | HEAD request The addFilePara method cannot be called!"); + throw new InternalException("GET | HEAD request The addFilePara method cannot be called!"); } } if (ObjectKit.isNotEmpty(requestBody)) { if (MapKit.isNotEmpty(bodyParams)) { - throw new InstrumentException("The methods addBodyPara and setBodyPara cannot be called at the same time!"); + throw new InternalException("The methods addBodyPara and setBodyPara cannot be called at the same time!"); } if (MapKit.isNotEmpty(files)) { - throw new InstrumentException("The methods addFilePara and setBodyPara cannot be called at the same time!"); + throw new InternalException("The methods addFilePara and setBodyPara cannot be called at the same time!"); } } } @@ -728,7 +728,7 @@ protected boolean timeoutAwait(CountDownLatch latch) { return latch.await(httpv.preprocTimeoutMillis(), TimeUnit.MILLISECONDS); } catch (InterruptedException e) { - throw new InstrumentException("TimeOut " + CoverResult.State.TIMEOUT); + throw new InternalException("TimeOut " + CoverResult.State.TIMEOUT); } } @@ -736,7 +736,7 @@ protected CoverResult timeoutResult() { if (nothrow) { return new CoverResult.Real(this, CoverResult.State.TIMEOUT); } - throw new InstrumentException("Execution timeout " + CoverResult.State.TIMEOUT); + throw new InternalException("Execution timeout " + CoverResult.State.TIMEOUT); } public Charset charset(Response response) { @@ -879,7 +879,7 @@ public CoverResult request(String method) { CoverResult.State state = result.getState(); if (null != e && state != CoverResult.State.CANCELED && !nothrow) { - throw new InstrumentException("Abnormal execution", e); + throw new InternalException("Abnormal execution", e); } return result; } @@ -1055,7 +1055,7 @@ public void onFailure(NewCall call, IOException error) { executor.executeOnComplete(Async.this, onComplete, state, cOnIO); if (!executor.executeOnException(Async.this, onException, error, eOnIO) && !nothrow) { - throw new InstrumentException(error.getMessage(), error); + throw new InternalException(error.getMessage(), error); } }); } diff --git a/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/CoverTasks.java b/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/CoverTasks.java index 6c345c7471..042e753448 100644 --- a/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/CoverTasks.java +++ b/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/CoverTasks.java @@ -1,6 +1,6 @@ package org.aoju.bus.http.plugin.httpv; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Http; import org.aoju.bus.core.lang.MediaType; import org.aoju.bus.http.Callback; @@ -141,10 +141,10 @@ public Data doMsgConvert(String type, ConvertFunc callable) { return new Data<>(null, toMediaType(type)); } if (null != cause) { - throw new InstrumentException("Conversion failed", cause); + throw new InternalException("Conversion failed", cause); } - throw new InstrumentException("No match[" + type + "]Type converter!"); + throw new InternalException("No match[" + type + "]Type converter!"); } private String toMediaType(String type) { diff --git a/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/Downloads.java b/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/Downloads.java index d879550881..bd23dda763 100644 --- a/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/Downloads.java +++ b/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/Downloads.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.http.plugin.httpv; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.toolkit.IoKit; import org.aoju.bus.http.Callback; @@ -167,7 +167,7 @@ private RandomAccessFile randomAccessFile() { } catch (FileNotFoundException e) { status = Control.STATUS__ERROR; IoKit.close(input); - throw new InstrumentException("Can't get file [" + file.getAbsolutePath() + "] Input stream", e); + throw new InternalException("Can't get file [" + file.getAbsolutePath() + "] Input stream", e); } } @@ -211,7 +211,7 @@ private void doDownload(RandomAccessFile raFile) { onFailure.on(new Failure(e)); }, fOnIO); } else { - throw new InstrumentException("Streaming failed!", e); + throw new InternalException("Streaming failed!", e); } } finally { IoKit.close(raFile); diff --git a/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/ResultBody.java b/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/ResultBody.java index f12290563c..b9b4f6ae5c 100644 --- a/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/ResultBody.java +++ b/bus-http/src/main/java/org/aoju/bus/http/plugin/httpv/ResultBody.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.http.plugin.httpv; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.io.ByteString; import org.aoju.bus.core.io.buffer.Buffer; import org.aoju.bus.core.lang.*; @@ -211,7 +211,7 @@ public String toString() { return new String(body.bytes(), charset); } } catch (IOException e) { - throw new InstrumentException("Error in converting the body of the message!", e); + throw new InternalException("Error in converting the body of the message!", e); } return null; } @@ -240,7 +240,7 @@ public Downloads toFile(File file) { file.createNewFile(); } catch (IOException e) { response.close(); - throw new InstrumentException("Cannot create file [" + file.getAbsolutePath() + "]", e); + throw new InternalException("Cannot create file [" + file.getAbsolutePath() + "]", e); } } return executor.download(coverHttp, file, toByteStream(), @@ -265,7 +265,7 @@ public Downloads toFolder(String dirPath) { public Downloads toFolder(File dir) { if (dir.exists() && !dir.isDirectory()) { response.close(); - throw new InstrumentException("File download failed:[" + dir.getAbsolutePath() + "] Already exists and is not a directory !"); + throw new InternalException("File download failed:[" + dir.getAbsolutePath() + "] Already exists and is not a directory !"); } if (!dir.exists()) { dir.mkdirs(); @@ -303,7 +303,7 @@ private byte[] bodyToBytes() { try (Buffer buffer = new Buffer()) { return buffer.readFrom(toByteStream()).readByteArray(); } catch (IOException e) { - throw new InstrumentException("Error in converting byte array of message body!", e); + throw new InternalException("Error in converting byte array of message body!", e); } finally { response.close(); } @@ -313,7 +313,7 @@ private byte[] bodyToBytes() { try { return body.bytes(); } catch (IOException e) { - throw new InstrumentException("Error in converting byte array of message body!", e); + throw new InternalException("Error in converting byte array of message body!", e); } } return new byte[0]; @@ -369,7 +369,7 @@ private String resolveFileName() { fileName = URLDecoder.decode(fileName.substring( fileName.indexOf("filename=") + 9), Charset.DEFAULT_UTF_8); } catch (UnsupportedEncodingException e) { - throw new InstrumentException("Failed to decode file name", e); + throw new InternalException("Failed to decode file name", e); } // 去掉文件名会被包含"",不然无法读取文件后缀 fileName = fileName.replaceAll("\"", Normal.EMPTY); diff --git a/bus-http/src/main/java/org/aoju/bus/http/secure/SSLContextBuilder.java b/bus-http/src/main/java/org/aoju/bus/http/secure/SSLContextBuilder.java index e53ddccf9a..f3cab6c3b5 100644 --- a/bus-http/src/main/java/org/aoju/bus/http/secure/SSLContextBuilder.java +++ b/bus-http/src/main/java/org/aoju/bus/http/secure/SSLContextBuilder.java @@ -26,7 +26,7 @@ package org.aoju.bus.http.secure; import org.aoju.bus.core.builder.Builder; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Http; import org.aoju.bus.core.toolkit.ArrayKit; import org.aoju.bus.core.toolkit.StringKit; @@ -76,9 +76,9 @@ public static SSLContextBuilder create() { * * @param protocol SSL协议,例如TLS等 * @return {@link SSLContext} - * @throws InstrumentException 包装 GeneralSecurityException异常 + * @throws InternalException 包装 GeneralSecurityException异常 */ - public static SSLContext createSSLContext(String protocol) throws InstrumentException { + public static SSLContext createSSLContext(String protocol) throws InternalException { return create().setProtocol(protocol).build(); } @@ -89,10 +89,10 @@ public static SSLContext createSSLContext(String protocol) throws InstrumentExce * @param keyManager 密钥管理器,{@code null}表示无 * @param trustManager 信任管理器, {@code null}表示无 * @return {@link SSLContext} - * @throws InstrumentException 包装 GeneralSecurityException异常 + * @throws InternalException 包装 GeneralSecurityException异常 */ public static SSLContext createSSLContext(String protocol, KeyManager keyManager, TrustManager trustManager) - throws InstrumentException { + throws InternalException { return createSSLContext(protocol, keyManager == null ? null : new KeyManager[]{keyManager}, trustManager == null ? null : new TrustManager[]{trustManager}); @@ -105,9 +105,9 @@ public static SSLContext createSSLContext(String protocol, KeyManager keyManager * @param keyManagers 密钥管理器,{@code null}表示无 * @param trustManagers 信任管理器, {@code null}表示无 * @return {@link SSLContext} - * @throws InstrumentException 包装 GeneralSecurityException异常 + * @throws InternalException 包装 GeneralSecurityException异常 */ - public static SSLContext createSSLContext(String protocol, KeyManager[] keyManagers, TrustManager[] trustManagers) throws InstrumentException { + public static SSLContext createSSLContext(String protocol, KeyManager[] keyManagers, TrustManager[] trustManagers) throws InternalException { return SSLContextBuilder.create() .setProtocol(protocol) .setKeyManagers(keyManagers) @@ -193,13 +193,13 @@ public SSLContext buildChecked() throws NoSuchAlgorithmException, KeyManagementE * 构建{@link SSLContext} * * @return {@link SSLContext} - * @throws InstrumentException 包装 GeneralSecurityException异常 + * @throws InternalException 包装 GeneralSecurityException异常 */ - public SSLContext buildQuietly() throws InstrumentException { + public SSLContext buildQuietly() throws InternalException { try { return buildChecked(); } catch (GeneralSecurityException e) { - throw new InstrumentException(e); + throw new InternalException(e); } } diff --git a/bus-image/pom.xml b/bus-image/pom.xml index a697f9d690..901439c25a 100755 --- a/bus-image/pom.xml +++ b/bus-image/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-image - 6.5.6 + 6.5.8 jar ${project.artifactId} diff --git a/bus-image/src/main/java/org/aoju/bus/image/Centre.java b/bus-image/src/main/java/org/aoju/bus/image/Centre.java index b66c416343..68d4ff17eb 100644 --- a/bus-image/src/main/java/org/aoju/bus/image/Centre.java +++ b/bus-image/src/main/java/org/aoju/bus/image/Centre.java @@ -27,7 +27,7 @@ import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.core.lang.Symbol; import org.aoju.bus.core.toolkit.BooleanKit; import org.aoju.bus.core.toolkit.ObjectKit; @@ -114,7 +114,7 @@ public synchronized void start(boolean... flag) { } if (storeSCP.getConnection().isListening()) { - throw new InstrumentException("Cannot start a Listener because it is already running."); + throw new InternalException("Cannot start a Listener because it is already running."); } if (ObjectKit.isEmpty(storeSCP)) { diff --git a/bus-image/src/main/java/org/aoju/bus/image/galaxy/ApplicationCache.java b/bus-image/src/main/java/org/aoju/bus/image/galaxy/ApplicationCache.java index 98f91a539d..e0e4301622 100755 --- a/bus-image/src/main/java/org/aoju/bus/image/galaxy/ApplicationCache.java +++ b/bus-image/src/main/java/org/aoju/bus/image/galaxy/ApplicationCache.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.image.galaxy; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.image.metric.WebApplication; /** @@ -40,8 +40,8 @@ public interface ApplicationCache { void clear(); - WebApplication get(String aet) throws InstrumentException; + WebApplication get(String aet) throws InternalException; - WebApplication findWebApplication(String name) throws InstrumentException; + WebApplication findWebApplication(String name) throws InternalException; } diff --git a/bus-image/src/main/java/org/aoju/bus/image/galaxy/Configuration.java b/bus-image/src/main/java/org/aoju/bus/image/galaxy/Configuration.java index 90271509f4..dbd2846f33 100755 --- a/bus-image/src/main/java/org/aoju/bus/image/galaxy/Configuration.java +++ b/bus-image/src/main/java/org/aoju/bus/image/galaxy/Configuration.java @@ -25,7 +25,7 @@ ********************************************************************************/ package org.aoju.bus.image.galaxy; -import org.aoju.bus.core.exception.InstrumentException; +import org.aoju.bus.core.exception.InternalException; import org.aoju.bus.image.Device; import org.aoju.bus.image.metric.ApplicationEntity; import org.aoju.bus.image.metric.WebApplication; @@ -41,71 +41,71 @@ public interface Configuration extends Closeable { WebApplication[] listWebApplicationInfos(WebApplication keys) - throws InstrumentException; + throws InternalException; - boolean configurationExists() throws InstrumentException; + boolean configurationExists() throws InternalException; - boolean purgeConfiguration() throws InstrumentException; + boolean purgeConfiguration() throws InternalException; - boolean registerAETitle(String aet) throws InstrumentException; + boolean registerAETitle(String aet) throws InternalException; - boolean registerWebAppName(String webAppName) throws InstrumentException; + boolean registerWebAppName(String webAppName) throws InternalException; - void unregisterAETitle(String aet) throws InstrumentException; + void unregisterAETitle(String aet) throws InternalException; - void unregisterWebAppName(String webAppName) throws InstrumentException; + void unregisterWebAppName(String webAppName) throws InternalException; - ApplicationEntity findApplicationEntity(String aet) throws InstrumentException; + ApplicationEntity findApplicationEntity(String aet) throws InternalException; - WebApplication findWebApplication(String name) throws InstrumentException; + WebApplication findWebApplication(String name) throws InternalException; - Device findDevice(String name) throws InstrumentException; + Device findDevice(String name) throws InternalException; /** * 查询具有指定属性的设备 * * @param keys 设备属性必须与*匹配或为空,以获取所有已配置设备的信息 * @return 具有匹配属性的已配置设备*的DeviceInfo对象数组 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - Device[] listDeviceInfos(Device keys) throws InstrumentException; + Device[] listDeviceInfos(Device keys) throws InternalException; /** * 查询具有指定属性的应用程序实体 * * @param keys 应与匹配或为空的应用程序实体属性将获取所有已配置的应用程序实体的信息 * @return 具有匹配属性的已配置应用程序实体*的ApplicationEntityInfo对象数组 - * @throws InstrumentException 异常 + * @throws InternalException 异常 */ - ApplicationEntity[] listAETInfos(ApplicationEntity keys) throws InstrumentException; + ApplicationEntity[] listAETInfos(ApplicationEntity keys) throws InternalException; - String[] listDeviceNames() throws InstrumentException; + String[] listDeviceNames() throws InternalException; - String[] listRegisteredAETitles() throws InstrumentException; + String[] listRegisteredAETitles() throws InternalException; - String[] listRegisteredWebAppNames() throws InstrumentException; + String[] listRegisteredWebAppNames() throws InternalException; - ConfigurationChange persist(Device device, EnumSet