mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -849,8 +849,8 @@ public class IoUtil extends NioUtil {
|
||||
* @throws IORuntimeException IO异常
|
||||
* @since 3.1.1
|
||||
*/
|
||||
public static void writeUtf8(final OutputStream out, final boolean isCloseOut, final Object... contents) throws IORuntimeException {
|
||||
write(out, CharsetUtil.UTF_8, isCloseOut, contents);
|
||||
public static void writeUtf8(final OutputStream out, final boolean isCloseOut, final CharSequence... contents) throws IORuntimeException {
|
||||
writeStrs(out, CharsetUtil.UTF_8, isCloseOut, contents);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -863,8 +863,8 @@ public class IoUtil extends NioUtil {
|
||||
* @throws IORuntimeException IO异常
|
||||
* @since 3.0.9
|
||||
*/
|
||||
public static void write(final OutputStream out, final Charset charset, final boolean isCloseOut, final Object... contents) throws IORuntimeException {
|
||||
StreamWriter.of(out, isCloseOut).writeStr(charset, contents);
|
||||
public static void writeStrs(final OutputStream out, final Charset charset, final boolean isCloseOut, final CharSequence... contents) throws IORuntimeException {
|
||||
StreamWriter.of(out, isCloseOut).writeStrs(charset, contents);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -876,7 +876,7 @@ public class IoUtil extends NioUtil {
|
||||
* @throws IORuntimeException IO异常
|
||||
*/
|
||||
public static void writeObjects(final OutputStream out, final boolean isCloseOut, final Object... contents) throws IORuntimeException {
|
||||
StreamWriter.of(out, isCloseOut).writeObj(contents);
|
||||
StreamWriter.of(out, isCloseOut).writeObjs(contents);
|
||||
}
|
||||
// endregion ----------------------------------------------------------------------------------------------- write
|
||||
|
||||
|
@@ -12,10 +12,8 @@
|
||||
|
||||
package org.dromara.hutool.core.io.stream;
|
||||
|
||||
import org.dromara.hutool.core.convert.Convert;
|
||||
import org.dromara.hutool.core.io.IORuntimeException;
|
||||
import org.dromara.hutool.core.io.IoUtil;
|
||||
import org.dromara.hutool.core.text.StrUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
@@ -80,7 +78,7 @@ public class StreamWriter {
|
||||
* @param contents 写入的内容
|
||||
* @throws IORuntimeException IO异常
|
||||
*/
|
||||
public void writeObj(final Object... contents) throws IORuntimeException {
|
||||
public void writeObjs(final Object... contents) throws IORuntimeException {
|
||||
ObjectOutputStream osw = null;
|
||||
try {
|
||||
osw = out instanceof ObjectOutputStream ? (ObjectOutputStream) out : new ObjectOutputStream(out);
|
||||
@@ -106,13 +104,13 @@ public class StreamWriter {
|
||||
* @param contents 写入的内容,调用toString()方法,不包括不会自动换行
|
||||
* @throws IORuntimeException IO异常
|
||||
*/
|
||||
public void writeStr(final Charset charset, final Object... contents) throws IORuntimeException {
|
||||
public void writeStrs(final Charset charset, final CharSequence... contents) throws IORuntimeException {
|
||||
OutputStreamWriter osw = null;
|
||||
try {
|
||||
osw = IoUtil.toWriter(out, charset);
|
||||
for (final Object content : contents) {
|
||||
for (final CharSequence content : contents) {
|
||||
if (content != null) {
|
||||
osw.write(Convert.toStr(content, StrUtil.EMPTY));
|
||||
osw.write(content.toString());
|
||||
}
|
||||
}
|
||||
osw.flush();
|
||||
|
Reference in New Issue
Block a user