public class MultipartOutputStream extends OutputStream
| Constructor and Description |
|---|
MultipartOutputStream(OutputStream out,
Charset charset)
构造,使用全局默认的边界字符串
|
MultipartOutputStream(OutputStream out,
Charset charset,
String boundary)
构造
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
finish()
上传表单结束
|
void |
write(int b) |
MultipartOutputStream |
write(String formFieldName,
Object value)
添加Multipart表单的数据项
--分隔符(boundary)[换行] Content-Disposition: form-data; name="参数名"[换行] [换行] 参数值[换行] 或者: --分隔符(boundary)[换行] Content-Disposition: form-data; name="表单名"; filename="文件名"[换行] Content-Type: MIME类型[换行] [换行] 文件的二进制内容[换行] |
flush, write, writepublic MultipartOutputStream(OutputStream out, Charset charset)
out - HTTP写出流charset - 编码public MultipartOutputStream(OutputStream out, Charset charset, String boundary)
out - HTTP写出流charset - 编码boundary - 边界符public MultipartOutputStream write(String formFieldName, Object value) throws IORuntimeException
--分隔符(boundary)[换行]
Content-Disposition: form-data; name="参数名"[换行]
[换行]
参数值[换行]
或者:
--分隔符(boundary)[换行]
Content-Disposition: form-data; name="表单名"; filename="文件名"[换行]
Content-Type: MIME类型[换行]
[换行]
文件的二进制内容[换行]
formFieldName - 表单名value - 值,可以是普通值、资源(如文件等)IORuntimeException - IO异常public void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void finish()
throws IORuntimeException
IORuntimeException - IO异常public void close()
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamCopyright © 2025. All rights reserved.