mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
1ad628f944
commit
c1a895bce5
@ -138,18 +138,18 @@ We provide the T-Shirt and Sweater with Hutool Logo, please visit the shop:
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
### 🍐Gradle
|
### 🍐Gradle
|
||||||
```
|
```
|
||||||
implementation 'cn.hutool:hutool-all:6.0.0.M1'
|
implementation 'cn.hutool:hutool-all:6.0.0.M2'
|
||||||
```
|
```
|
||||||
|
|
||||||
## 📥Download
|
## 📥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:
|
> 🔔️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.
|
> Hutool 5.x supports JDK8+ and is not tested on Android platforms, and cannot guarantee that all tool classes or tool methods are available.
|
||||||
|
@ -141,21 +141,21 @@ Hutool的存在就是为了减少代码搜索成本,避免网络上参差不
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
### 🍐Gradle
|
### 🍐Gradle
|
||||||
|
|
||||||
```
|
```
|
||||||
implementation 'cn.hutool:hutool-all:6.0.0.M1'
|
implementation 'cn.hutool:hutool-all:6.0.0.M2'
|
||||||
```
|
```
|
||||||
|
|
||||||
### 📥下载jar
|
### 📥下载jar
|
||||||
|
|
||||||
点击以下链接,下载`hutool-all-X.X.X.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平台没有测试,不能保证所有工具类或工具方法可用。
|
> Hutool 5.x支持JDK8+,对Android平台没有测试,不能保证所有工具类或工具方法可用。
|
||||||
|
@ -1 +1 @@
|
|||||||
6.0.0.M1
|
6.0.0.M2
|
||||||
|
@ -1 +1 @@
|
|||||||
var version = '6.0.0.M1'
|
var version = '6.0.0.M2'
|
@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-parent</artifactId>
|
<artifactId>hutool-parent</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-parent</artifactId>
|
<artifactId>hutool-parent</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hutool-bom</artifactId>
|
<artifactId>hutool-bom</artifactId>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-parent</artifactId>
|
<artifactId>hutool-parent</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hutool-core</artifactId>
|
<artifactId>hutool-core</artifactId>
|
||||||
|
@ -48,15 +48,15 @@ public class SyncInputStream extends FilterInputStream {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步数据到内存
|
* 同步数据到内存
|
||||||
|
* @return this
|
||||||
*/
|
*/
|
||||||
public void sync() {
|
public SyncInputStream sync() {
|
||||||
if (false == asyncFlag) {
|
if (asyncFlag) {
|
||||||
// 已经是同步模式
|
this.in = new ByteArrayInputStream(readBytes());
|
||||||
return;
|
this.asyncFlag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.in = new ByteArrayInputStream(readBytes());
|
return this;
|
||||||
this.asyncFlag = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-parent</artifactId>
|
<artifactId>hutool-parent</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hutool-cron</artifactId>
|
<artifactId>hutool-cron</artifactId>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-parent</artifactId>
|
<artifactId>hutool-parent</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hutool-crypto</artifactId>
|
<artifactId>hutool-crypto</artifactId>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-parent</artifactId>
|
<artifactId>hutool-parent</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hutool-db</artifactId>
|
<artifactId>hutool-db</artifactId>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-parent</artifactId>
|
<artifactId>hutool-parent</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hutool-extra</artifactId>
|
<artifactId>hutool-extra</artifactId>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-parent</artifactId>
|
<artifactId>hutool-parent</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hutool-http</artifactId>
|
<artifactId>hutool-http</artifactId>
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
package cn.hutool.http.client;
|
package cn.hutool.http.client;
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
import cn.hutool.http.HttpException;
|
import cn.hutool.http.HttpException;
|
||||||
import cn.hutool.http.client.body.ResponseBody;
|
import cn.hutool.http.client.body.ResponseBody;
|
||||||
import cn.hutool.http.html.HtmlUtil;
|
|
||||||
import cn.hutool.http.meta.ContentTypeUtil;
|
import cn.hutool.http.meta.ContentTypeUtil;
|
||||||
import cn.hutool.http.meta.Header;
|
import cn.hutool.http.meta.Header;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -79,17 +80,25 @@ public interface Response extends Closeable {
|
|||||||
* @throws HttpException 包装IO异常
|
* @throws HttpException 包装IO异常
|
||||||
*/
|
*/
|
||||||
default String bodyStr() throws HttpException {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取响应流字节码<br>
|
* 获取响应流字节码<br>
|
||||||
* 此方法会转为同步模式
|
* 此方法会转为同步模式,读取响应流并关闭之
|
||||||
*
|
*
|
||||||
* @return byte[]
|
* @return byte[]
|
||||||
*/
|
*/
|
||||||
default byte[] bodyBytes() {
|
default byte[] bodyBytes() {
|
||||||
return body().getBytes();
|
try(final ResponseBody body = body()){
|
||||||
|
return body.getBytes();
|
||||||
|
} catch (final IOException e) {
|
||||||
|
throw new IORuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,6 +11,7 @@ import cn.hutool.core.text.StrUtil;
|
|||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.hutool.http.HttpException;
|
import cn.hutool.http.HttpException;
|
||||||
import cn.hutool.http.client.Response;
|
import cn.hutool.http.client.Response;
|
||||||
|
import cn.hutool.http.html.HtmlUtil;
|
||||||
import cn.hutool.http.meta.Header;
|
import cn.hutool.http.meta.Header;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
@ -79,6 +80,15 @@ public class ResponseBody implements HttpBody, Closeable {
|
|||||||
return this.bodyStream.readBytes();
|
return this.bodyStream.readBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取响应字符串,自动识别判断编码
|
||||||
|
*
|
||||||
|
* @return 响应字符串
|
||||||
|
*/
|
||||||
|
public String getString() {
|
||||||
|
return HtmlUtil.getString(getBytes(), response.charset(), true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将响应内容写出到{@link OutputStream}<br>
|
* 将响应内容写出到{@link OutputStream}<br>
|
||||||
* 异步模式下直接读取Http流写出,同步模式下将存储在内存中的响应内容写出<br>
|
* 异步模式下直接读取Http流写出,同步模式下将存储在内存中的响应内容写出<br>
|
||||||
@ -189,6 +199,11 @@ public class ResponseBody implements HttpBody, Closeable {
|
|||||||
this.bodyStream.close();
|
this.bodyStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getString();
|
||||||
|
}
|
||||||
|
|
||||||
// region ---------------------------------------------------------------------------- Private Methods
|
// region ---------------------------------------------------------------------------- Private Methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,14 +3,13 @@ package cn.hutool.http.client;
|
|||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
import cn.hutool.http.client.engine.httpclient4.HttpClient4Engine;
|
import cn.hutool.http.client.engine.httpclient4.HttpClient4Engine;
|
||||||
import cn.hutool.http.meta.Method;
|
import cn.hutool.http.meta.Method;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class HttpClient4EngineTest {
|
public class HttpClient4EngineTest {
|
||||||
|
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
//@Ignore
|
||||||
public void getTest() {
|
public void getTest() {
|
||||||
final ClientEngine engine = new HttpClient4Engine();
|
final ClientEngine engine = new HttpClient4Engine();
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package cn.hutool.http.client;
|
package cn.hutool.http.client;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
import cn.hutool.http.meta.Method;
|
|
||||||
import cn.hutool.http.client.engine.httpclient5.HttpClient5Engine;
|
import cn.hutool.http.client.engine.httpclient5.HttpClient5Engine;
|
||||||
|
import cn.hutool.http.meta.Method;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -18,6 +18,6 @@ public class HttpClient5EngineTest {
|
|||||||
final Response res = engine.send(req);
|
final Response res = engine.send(req);
|
||||||
|
|
||||||
Console.log(res.getStatus());
|
Console.log(res.getStatus());
|
||||||
Console.log(res.body());
|
Console.log(res.bodyStr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-parent</artifactId>
|
<artifactId>hutool-parent</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hutool-json</artifactId>
|
<artifactId>hutool-json</artifactId>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-parent</artifactId>
|
<artifactId>hutool-parent</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hutool-log</artifactId>
|
<artifactId>hutool-log</artifactId>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-parent</artifactId>
|
<artifactId>hutool-parent</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hutool-poi</artifactId>
|
<artifactId>hutool-poi</artifactId>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-parent</artifactId>
|
<artifactId>hutool-parent</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hutool-setting</artifactId>
|
<artifactId>hutool-setting</artifactId>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-parent</artifactId>
|
<artifactId>hutool-parent</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hutool-socket</artifactId>
|
<artifactId>hutool-socket</artifactId>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-parent</artifactId>
|
<artifactId>hutool-parent</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hutool-swing</artifactId>
|
<artifactId>hutool-swing</artifactId>
|
||||||
|
2
pom.xml
2
pom.xml
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-parent</artifactId>
|
<artifactId>hutool-parent</artifactId>
|
||||||
<version>6.0.0.M1</version>
|
<version>6.0.0.M2</version>
|
||||||
<name>hutool</name>
|
<name>hutool</name>
|
||||||
<description>Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。</description>
|
<description>Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。</description>
|
||||||
<url>https://github.com/dromara/hutool</url>
|
<url>https://github.com/dromara/hutool</url>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user