mirror of
https://gitee.com/dromara/hutool.git
synced 2025-11-24 16:43:24 +08:00
IoUtil.writeObjects判空避免空指针(issue#4049@Github)
This commit is contained in:
@@ -6,6 +6,7 @@ import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.io.copy.ReaderWriterCopier;
|
||||
import cn.hutool.core.io.copy.StreamCopier;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.HexUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -1071,6 +1072,10 @@ public class IoUtil extends NioUtil {
|
||||
public static void writeObjects(OutputStream out, boolean isCloseOut, Serializable... contents) throws IORuntimeException {
|
||||
ObjectOutputStream osw = null;
|
||||
try {
|
||||
if(ArrayUtil.isEmpty( contents)){
|
||||
return;
|
||||
}
|
||||
|
||||
osw = out instanceof ObjectOutputStream ? (ObjectOutputStream) out : new ObjectOutputStream(out);
|
||||
for (Object content : contents) {
|
||||
if (content != null) {
|
||||
|
||||
Reference in New Issue
Block a user