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
52cf8fdc71
commit
fbe899dd2a
@ -849,8 +849,8 @@ public class IoUtil extends NioUtil {
|
|||||||
* @throws IORuntimeException IO异常
|
* @throws IORuntimeException IO异常
|
||||||
* @since 3.1.1
|
* @since 3.1.1
|
||||||
*/
|
*/
|
||||||
public static void writeUtf8(final OutputStream out, final boolean isCloseOut, final Object... contents) throws IORuntimeException {
|
public static void writeUtf8(final OutputStream out, final boolean isCloseOut, final CharSequence... contents) throws IORuntimeException {
|
||||||
write(out, CharsetUtil.UTF_8, isCloseOut, contents);
|
writeStrs(out, CharsetUtil.UTF_8, isCloseOut, contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -863,8 +863,8 @@ public class IoUtil extends NioUtil {
|
|||||||
* @throws IORuntimeException IO异常
|
* @throws IORuntimeException IO异常
|
||||||
* @since 3.0.9
|
* @since 3.0.9
|
||||||
*/
|
*/
|
||||||
public static void write(final OutputStream out, final Charset charset, final boolean isCloseOut, final Object... contents) throws IORuntimeException {
|
public static void writeStrs(final OutputStream out, final Charset charset, final boolean isCloseOut, final CharSequence... contents) throws IORuntimeException {
|
||||||
StreamWriter.of(out, isCloseOut).writeStr(charset, contents);
|
StreamWriter.of(out, isCloseOut).writeStrs(charset, contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -876,7 +876,7 @@ public class IoUtil extends NioUtil {
|
|||||||
* @throws IORuntimeException IO异常
|
* @throws IORuntimeException IO异常
|
||||||
*/
|
*/
|
||||||
public static void writeObjects(final OutputStream out, final boolean isCloseOut, final Object... contents) throws IORuntimeException {
|
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
|
// endregion ----------------------------------------------------------------------------------------------- write
|
||||||
|
|
||||||
|
@ -12,10 +12,8 @@
|
|||||||
|
|
||||||
package org.dromara.hutool.core.io.stream;
|
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.IORuntimeException;
|
||||||
import org.dromara.hutool.core.io.IoUtil;
|
import org.dromara.hutool.core.io.IoUtil;
|
||||||
import org.dromara.hutool.core.text.StrUtil;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
@ -80,7 +78,7 @@ public class StreamWriter {
|
|||||||
* @param contents 写入的内容
|
* @param contents 写入的内容
|
||||||
* @throws IORuntimeException IO异常
|
* @throws IORuntimeException IO异常
|
||||||
*/
|
*/
|
||||||
public void writeObj(final Object... contents) throws IORuntimeException {
|
public void writeObjs(final Object... contents) throws IORuntimeException {
|
||||||
ObjectOutputStream osw = null;
|
ObjectOutputStream osw = null;
|
||||||
try {
|
try {
|
||||||
osw = out instanceof ObjectOutputStream ? (ObjectOutputStream) out : new ObjectOutputStream(out);
|
osw = out instanceof ObjectOutputStream ? (ObjectOutputStream) out : new ObjectOutputStream(out);
|
||||||
@ -106,13 +104,13 @@ public class StreamWriter {
|
|||||||
* @param contents 写入的内容,调用toString()方法,不包括不会自动换行
|
* @param contents 写入的内容,调用toString()方法,不包括不会自动换行
|
||||||
* @throws IORuntimeException IO异常
|
* @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;
|
OutputStreamWriter osw = null;
|
||||||
try {
|
try {
|
||||||
osw = IoUtil.toWriter(out, charset);
|
osw = IoUtil.toWriter(out, charset);
|
||||||
for (final Object content : contents) {
|
for (final CharSequence content : contents) {
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
osw.write(Convert.toStr(content, StrUtil.EMPTY));
|
osw.write(content.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
osw.flush();
|
osw.flush();
|
||||||
|
@ -107,19 +107,19 @@ public class MultipartOutputStream extends OutputStream {
|
|||||||
|
|
||||||
if (value instanceof Resource) {
|
if (value instanceof Resource) {
|
||||||
appendResource(formFieldName, (Resource) value);
|
appendResource(formFieldName, (Resource) value);
|
||||||
}else if(value instanceof File) {
|
} else if (value instanceof File) {
|
||||||
appendResource(formFieldName, new FileResource((File) value));
|
appendResource(formFieldName, new FileResource((File) value));
|
||||||
}else if(value instanceof Path) {
|
} else if (value instanceof Path) {
|
||||||
appendResource(formFieldName, new FileResource((Path) value));
|
appendResource(formFieldName, new FileResource((Path) value));
|
||||||
} else if(value instanceof byte[]) {
|
} else if (value instanceof byte[]) {
|
||||||
appendResource(formFieldName, new BytesResource((byte[]) value));
|
appendResource(formFieldName, new BytesResource((byte[]) value));
|
||||||
} else if(value instanceof InputStream) {
|
} else if (value instanceof InputStream) {
|
||||||
appendResource(formFieldName, new InputStreamResource((InputStream) value));
|
appendResource(formFieldName, new InputStreamResource((InputStream) value));
|
||||||
} else if(value instanceof Reader) {
|
} else if (value instanceof Reader) {
|
||||||
appendResource(formFieldName, new InputStreamResource((Reader) value, this.charset));
|
appendResource(formFieldName, new InputStreamResource((Reader) value, this.charset));
|
||||||
} else {
|
} else {
|
||||||
appendResource(formFieldName,
|
appendResource(formFieldName,
|
||||||
new StringResource(Convert.toStr(value), null, this.charset));
|
new StringResource(Convert.toStr(value), null, this.charset));
|
||||||
}
|
}
|
||||||
|
|
||||||
write(StrUtil.CRLF);
|
write(StrUtil.CRLF);
|
||||||
@ -178,11 +178,11 @@ public class MultipartOutputStream extends OutputStream {
|
|||||||
} else if (StrUtil.isNotEmpty(fileName)) {
|
} else if (StrUtil.isNotEmpty(fileName)) {
|
||||||
// 根据name的扩展名指定互联网媒体类型,默认二进制流数据
|
// 根据name的扩展名指定互联网媒体类型,默认二进制流数据
|
||||||
write(StrUtil.format(CONTENT_TYPE_FILE_TEMPLATE,
|
write(StrUtil.format(CONTENT_TYPE_FILE_TEMPLATE,
|
||||||
FileUtil.getMimeType(fileName, ContentType.OCTET_STREAM.getValue())));
|
FileUtil.getMimeType(fileName, ContentType.OCTET_STREAM.getValue())));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 内容
|
// 内容
|
||||||
write("\r\n");
|
write(StrUtil.CRLF);
|
||||||
resource.writeTo(this);
|
resource.writeTo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,9 +200,9 @@ public class MultipartOutputStream extends OutputStream {
|
|||||||
/**
|
/**
|
||||||
* 写出对象
|
* 写出对象
|
||||||
*
|
*
|
||||||
* @param objs 写出的对象(转换为字符串)
|
* @param contents 写出的字符串
|
||||||
*/
|
*/
|
||||||
private void write(final Object... objs) {
|
private void write(final CharSequence... contents) {
|
||||||
IoUtil.write(this, this.charset, false, objs);
|
IoUtil.writeStrs(this, this.charset, false, contents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user