diff --git a/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java b/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java index ae35f4c3f..bd4d160b6 100644 --- a/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java @@ -251,6 +251,19 @@ public class DateUtil extends CalendarUtil { return DateTime.of(date).dayOfMonth(); } + /** + * 获得指定日期是这个日期所在月份的第几天
+ * + * @param date 日期 + * @return 天 + * issue#896@Github + */ + public static int dayOfYear(Date date) { + Calendar instance = Calendar.getInstance(); + instance.setTime(date); + return instance.get(Calendar.DAY_OF_YEAR); + } + /** * 获得指定日期是星期几,1表示周日,2表示周一 * diff --git a/hutool-core/src/main/java/cn/hutool/core/util/StrUtil.java b/hutool-core/src/main/java/cn/hutool/core/util/StrUtil.java index 0d0bc15b1..9b11156d6 100644 --- a/hutool-core/src/main/java/cn/hutool/core/util/StrUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/util/StrUtil.java @@ -345,6 +345,17 @@ public class StrUtil { return true; } + /** + * 是否存都不为{@code null}或空对象,通过{@link StrUtil#hasEmpty(CharSequence...)} 判断元素 + * + * @param args 被检查的对象,一个或者多个 + * @return 是否都不为空 + * @since 5.3.5 + */ + public static boolean isAllNotEmpty(CharSequence... args) { + return false == hasEmpty(args); + } + /** * 检查字符串是否为null、“null”、“undefined” * diff --git a/hutool-http/src/main/java/cn/hutool/http/HttpUtil.java b/hutool-http/src/main/java/cn/hutool/http/HttpUtil.java index a9944159f..0ad059d8b 100644 --- a/hutool-http/src/main/java/cn/hutool/http/HttpUtil.java +++ b/hutool-http/src/main/java/cn/hutool/http/HttpUtil.java @@ -352,6 +352,27 @@ public class HttpUtil { return response.writeBody(out, isCloseOut, streamProgress); } + /** + + * 下载远程文件数据 + * + * @param url 请求的url + * @return 文件数据 + */ + public static byte[] downloadBytes(String url) { + if (StrUtil.isBlank(url)) { + throw new NullPointerException("[url] is null!"); + } + + HttpRequest request = new HttpRequest(url); + request.setFollowRedirects(true); + final HttpResponse response = request.executeAsync(); + if (false == response.isOk()) { + throw new HttpException("Server response error with status code: [{}]", response.getStatus()); + } + return response.bodyBytes(); + } + /** * 将Map形式的Form表单数据转换为Url参数形式,会自动url编码键和值 *