diff --git a/README-EN.md b/README-EN.md
index 0aca83d4a..6f7207f02 100755
--- a/README-EN.md
+++ b/README-EN.md
@@ -138,18 +138,18 @@ We provide the T-Shirt and Sweater with Hutool Logo, please visit the shop:
cn.hutool
hutool-all
- 6.0.0.M1
+ 6.0.0.M2
```
### 🍐Gradle
```
-implementation 'cn.hutool:hutool-all:6.0.0.M1'
+implementation 'cn.hutool:hutool-all:6.0.0.M2'
```
## 📥Download
-- [Maven Repo](https://repo1.maven.org/maven2/cn/hutool/hutool-all/6.0.0.M1/)
+- [Maven Repo](https://repo1.maven.org/maven2/cn/hutool/hutool-all/6.0.0.M2/)
> 🔔️note:
> Hutool 5.x supports JDK8+ and is not tested on Android platforms, and cannot guarantee that all tool classes or tool methods are available.
diff --git a/README.md b/README.md
index dda1ddff4..40a1b3e99 100755
--- a/README.md
+++ b/README.md
@@ -141,21 +141,21 @@ Hutool的存在就是为了减少代码搜索成本,避免网络上参差不
cn.hutool
hutool-all
- 6.0.0.M1
+ 6.0.0.M2
```
### 🍐Gradle
```
-implementation 'cn.hutool:hutool-all:6.0.0.M1'
+implementation 'cn.hutool:hutool-all:6.0.0.M2'
```
### 📥下载jar
点击以下链接,下载`hutool-all-X.X.X.jar`即可:
-- [Maven中央库](https://repo1.maven.org/maven2/cn/hutool/hutool-all/6.0.0.M1/)
+- [Maven中央库](https://repo1.maven.org/maven2/cn/hutool/hutool-all/6.0.0.M2/)
> 🔔️注意
> Hutool 5.x支持JDK8+,对Android平台没有测试,不能保证所有工具类或工具方法可用。
diff --git a/bin/version.txt b/bin/version.txt
index c946d3d40..95e0d8a6f 100755
--- a/bin/version.txt
+++ b/bin/version.txt
@@ -1 +1 @@
-6.0.0.M1
+6.0.0.M2
diff --git a/docs/js/version.js b/docs/js/version.js
index a5763db79..7b755716b 100755
--- a/docs/js/version.js
+++ b/docs/js/version.js
@@ -1 +1 @@
-var version = '6.0.0.M1'
\ No newline at end of file
+var version = '6.0.0.M2'
\ No newline at end of file
diff --git a/hutool-all/pom.xml b/hutool-all/pom.xml
index 5f87a6a2a..808274d2b 100755
--- a/hutool-all/pom.xml
+++ b/hutool-all/pom.xml
@@ -9,7 +9,7 @@
cn.hutool
hutool-parent
- 6.0.0.M1
+ 6.0.0.M2
hutool-all
diff --git a/hutool-bom/pom.xml b/hutool-bom/pom.xml
index 63b187098..e5ab0a02b 100755
--- a/hutool-bom/pom.xml
+++ b/hutool-bom/pom.xml
@@ -9,7 +9,7 @@
cn.hutool
hutool-parent
- 6.0.0.M1
+ 6.0.0.M2
hutool-bom
diff --git a/hutool-core/pom.xml b/hutool-core/pom.xml
index 261ff8b03..7db304dc5 100755
--- a/hutool-core/pom.xml
+++ b/hutool-core/pom.xml
@@ -9,7 +9,7 @@
cn.hutool
hutool-parent
- 6.0.0.M1
+ 6.0.0.M2
hutool-core
diff --git a/hutool-core/src/main/java/cn/hutool/core/io/stream/SyncInputStream.java b/hutool-core/src/main/java/cn/hutool/core/io/stream/SyncInputStream.java
index 08b22c990..fd2673db3 100755
--- a/hutool-core/src/main/java/cn/hutool/core/io/stream/SyncInputStream.java
+++ b/hutool-core/src/main/java/cn/hutool/core/io/stream/SyncInputStream.java
@@ -48,15 +48,15 @@ public class SyncInputStream extends FilterInputStream {
/**
* 同步数据到内存
+ * @return this
*/
- public void sync() {
- if (false == asyncFlag) {
- // 已经是同步模式
- return;
+ public SyncInputStream sync() {
+ if (asyncFlag) {
+ this.in = new ByteArrayInputStream(readBytes());
+ this.asyncFlag = false;
}
- this.in = new ByteArrayInputStream(readBytes());
- this.asyncFlag = false;
+ return this;
}
/**
diff --git a/hutool-cron/pom.xml b/hutool-cron/pom.xml
index 3ddae39f7..0e970ed12 100755
--- a/hutool-cron/pom.xml
+++ b/hutool-cron/pom.xml
@@ -9,7 +9,7 @@
cn.hutool
hutool-parent
- 6.0.0.M1
+ 6.0.0.M2
hutool-cron
diff --git a/hutool-crypto/pom.xml b/hutool-crypto/pom.xml
index 8f6f1050e..561ef5c25 100755
--- a/hutool-crypto/pom.xml
+++ b/hutool-crypto/pom.xml
@@ -9,7 +9,7 @@
cn.hutool
hutool-parent
- 6.0.0.M1
+ 6.0.0.M2
hutool-crypto
diff --git a/hutool-db/pom.xml b/hutool-db/pom.xml
index 02d148512..f2a251b9a 100755
--- a/hutool-db/pom.xml
+++ b/hutool-db/pom.xml
@@ -9,7 +9,7 @@
cn.hutool
hutool-parent
- 6.0.0.M1
+ 6.0.0.M2
hutool-db
diff --git a/hutool-extra/pom.xml b/hutool-extra/pom.xml
index 1a3a53e81..e2e010190 100755
--- a/hutool-extra/pom.xml
+++ b/hutool-extra/pom.xml
@@ -9,7 +9,7 @@
cn.hutool
hutool-parent
- 6.0.0.M1
+ 6.0.0.M2
hutool-extra
diff --git a/hutool-http/pom.xml b/hutool-http/pom.xml
index b6470b069..f0701fa19 100755
--- a/hutool-http/pom.xml
+++ b/hutool-http/pom.xml
@@ -9,7 +9,7 @@
cn.hutool
hutool-parent
- 6.0.0.M1
+ 6.0.0.M2
hutool-http
diff --git a/hutool-http/src/main/java/cn/hutool/http/client/Response.java b/hutool-http/src/main/java/cn/hutool/http/client/Response.java
index 991857ff7..3e587e7ca 100755
--- a/hutool-http/src/main/java/cn/hutool/http/client/Response.java
+++ b/hutool-http/src/main/java/cn/hutool/http/client/Response.java
@@ -1,14 +1,15 @@
package cn.hutool.http.client;
import cn.hutool.core.convert.Convert;
+import cn.hutool.core.io.IORuntimeException;
import cn.hutool.core.text.StrUtil;
import cn.hutool.http.HttpException;
import cn.hutool.http.client.body.ResponseBody;
-import cn.hutool.http.html.HtmlUtil;
import cn.hutool.http.meta.ContentTypeUtil;
import cn.hutool.http.meta.Header;
import java.io.Closeable;
+import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.List;
@@ -79,17 +80,25 @@ public interface Response extends Closeable {
* @throws HttpException 包装IO异常
*/
default String bodyStr() throws HttpException {
- return HtmlUtil.getString(bodyBytes(), charset(), true);
+ try(final ResponseBody body = body()){
+ return body.getString();
+ } catch (final IOException e) {
+ throw new IORuntimeException(e);
+ }
}
/**
* 获取响应流字节码
- * 此方法会转为同步模式
+ * 此方法会转为同步模式,读取响应流并关闭之
*
* @return byte[]
*/
default byte[] bodyBytes() {
- return body().getBytes();
+ try(final ResponseBody body = body()){
+ return body.getBytes();
+ } catch (final IOException e) {
+ throw new IORuntimeException(e);
+ }
}
/**
diff --git a/hutool-http/src/main/java/cn/hutool/http/client/body/ResponseBody.java b/hutool-http/src/main/java/cn/hutool/http/client/body/ResponseBody.java
index c1019d73c..c73eea208 100755
--- a/hutool-http/src/main/java/cn/hutool/http/client/body/ResponseBody.java
+++ b/hutool-http/src/main/java/cn/hutool/http/client/body/ResponseBody.java
@@ -11,6 +11,7 @@ import cn.hutool.core.text.StrUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.http.HttpException;
import cn.hutool.http.client.Response;
+import cn.hutool.http.html.HtmlUtil;
import cn.hutool.http.meta.Header;
import java.io.Closeable;
@@ -79,6 +80,15 @@ public class ResponseBody implements HttpBody, Closeable {
return this.bodyStream.readBytes();
}
+ /**
+ * 获取响应字符串,自动识别判断编码
+ *
+ * @return 响应字符串
+ */
+ public String getString() {
+ return HtmlUtil.getString(getBytes(), response.charset(), true);
+ }
+
/**
* 将响应内容写出到{@link OutputStream}
* 异步模式下直接读取Http流写出,同步模式下将存储在内存中的响应内容写出
@@ -189,6 +199,11 @@ public class ResponseBody implements HttpBody, Closeable {
this.bodyStream.close();
}
+ @Override
+ public String toString() {
+ return getString();
+ }
+
// region ---------------------------------------------------------------------------- Private Methods
/**
diff --git a/hutool-http/src/test/java/cn/hutool/http/client/HttpClient4EngineTest.java b/hutool-http/src/test/java/cn/hutool/http/client/HttpClient4EngineTest.java
index 2a5ef4f3e..1df07269c 100755
--- a/hutool-http/src/test/java/cn/hutool/http/client/HttpClient4EngineTest.java
+++ b/hutool-http/src/test/java/cn/hutool/http/client/HttpClient4EngineTest.java
@@ -3,14 +3,13 @@ package cn.hutool.http.client;
import cn.hutool.core.lang.Console;
import cn.hutool.http.client.engine.httpclient4.HttpClient4Engine;
import cn.hutool.http.meta.Method;
-import org.junit.Ignore;
import org.junit.Test;
public class HttpClient4EngineTest {
@SuppressWarnings("resource")
@Test
- @Ignore
+ //@Ignore
public void getTest() {
final ClientEngine engine = new HttpClient4Engine();
diff --git a/hutool-http/src/test/java/cn/hutool/http/client/HttpClient5EngineTest.java b/hutool-http/src/test/java/cn/hutool/http/client/HttpClient5EngineTest.java
index 6f069722b..c1b447ec0 100755
--- a/hutool-http/src/test/java/cn/hutool/http/client/HttpClient5EngineTest.java
+++ b/hutool-http/src/test/java/cn/hutool/http/client/HttpClient5EngineTest.java
@@ -1,8 +1,8 @@
package cn.hutool.http.client;
import cn.hutool.core.lang.Console;
-import cn.hutool.http.meta.Method;
import cn.hutool.http.client.engine.httpclient5.HttpClient5Engine;
+import cn.hutool.http.meta.Method;
import org.junit.Ignore;
import org.junit.Test;
@@ -18,6 +18,6 @@ public class HttpClient5EngineTest {
final Response res = engine.send(req);
Console.log(res.getStatus());
- Console.log(res.body());
+ Console.log(res.bodyStr());
}
}
diff --git a/hutool-json/pom.xml b/hutool-json/pom.xml
index 34a39eb72..5bcec276f 100755
--- a/hutool-json/pom.xml
+++ b/hutool-json/pom.xml
@@ -9,7 +9,7 @@
cn.hutool
hutool-parent
- 6.0.0.M1
+ 6.0.0.M2
hutool-json
diff --git a/hutool-log/pom.xml b/hutool-log/pom.xml
index 851b85afd..aa50c611f 100755
--- a/hutool-log/pom.xml
+++ b/hutool-log/pom.xml
@@ -9,7 +9,7 @@
cn.hutool
hutool-parent
- 6.0.0.M1
+ 6.0.0.M2
hutool-log
diff --git a/hutool-poi/pom.xml b/hutool-poi/pom.xml
index 78911842d..e2fd4b9e4 100755
--- a/hutool-poi/pom.xml
+++ b/hutool-poi/pom.xml
@@ -9,7 +9,7 @@
cn.hutool
hutool-parent
- 6.0.0.M1
+ 6.0.0.M2
hutool-poi
diff --git a/hutool-setting/pom.xml b/hutool-setting/pom.xml
index 62c38a6de..83e805888 100755
--- a/hutool-setting/pom.xml
+++ b/hutool-setting/pom.xml
@@ -9,7 +9,7 @@
cn.hutool
hutool-parent
- 6.0.0.M1
+ 6.0.0.M2
hutool-setting
diff --git a/hutool-socket/pom.xml b/hutool-socket/pom.xml
index 9bb0b5b37..8ef24bd07 100755
--- a/hutool-socket/pom.xml
+++ b/hutool-socket/pom.xml
@@ -9,7 +9,7 @@
cn.hutool
hutool-parent
- 6.0.0.M1
+ 6.0.0.M2
hutool-socket
diff --git a/hutool-swing/pom.xml b/hutool-swing/pom.xml
index 7764fdc24..2901b1bac 100755
--- a/hutool-swing/pom.xml
+++ b/hutool-swing/pom.xml
@@ -9,7 +9,7 @@
cn.hutool
hutool-parent
- 6.0.0.M1
+ 6.0.0.M2
hutool-swing
diff --git a/pom.xml b/pom.xml
index f06a4f123..1064a9236 100755
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
cn.hutool
hutool-parent
- 6.0.0.M1
+ 6.0.0.M2
hutool
Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。
https://github.com/dromara/hutool