Package org.codehaus.cargo.tools.daemon
Class MultipartFormWriter
- java.lang.Object
-
- org.codehaus.cargo.tools.daemon.MultipartFormWriter
-
public class MultipartFormWriter extends Object
Represents a form writer capable of sending files and form data as multipart chunks.
-
-
Constructor Summary
Constructors Constructor Description MultipartFormWriter(MultipartFormContentType contentType, OutputStream os)Attaches to the outputstream and allows writing form data or files to it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the writer.voidwriteField(String name, String value)Writes a string field value.voidwriteFile(String name, String mimeType, File file)Writes a file's contents.voidwriteFile(String name, String mimeType, String fileName, byte[] data)Writes the given bytes.voidwriteFile(String name, String mimeType, String fileName, InputStream is)Writes a input stream's contents.
-
-
-
Constructor Detail
-
MultipartFormWriter
public MultipartFormWriter(MultipartFormContentType contentType, OutputStream os)
Attaches to the outputstream and allows writing form data or files to it.- Parameters:
contentType- The form content typeos- the output stream
-
-
Method Detail
-
writeField
public void writeField(String name, String value) throws IOException
Writes a string field value.- Parameters:
name- the field name (required)value- the field value- Throws:
IOException- on input/output errors
-
writeFile
public void writeFile(String name, String mimeType, File file) throws IOException
Writes a file's contents.- Parameters:
name- the field namemimeType- the file content type (optional, recommended)file- the file (the file must exist)- Throws:
IOException- on input/output errors
-
writeFile
public void writeFile(String name, String mimeType, String fileName, InputStream is) throws IOException
Writes a input stream's contents.- Parameters:
name- The field namemimeType- The file content type (optional, recommended)fileName- The file name (required)is- The input stream- Throws:
IOException- on input/output errors
-
writeFile
public void writeFile(String name, String mimeType, String fileName, byte[] data) throws IOException
Writes the given bytes.- Parameters:
name- the field namemimeType- the file content type (optional, recommended)fileName- the file name (required)data- the file data- Throws:
IOException- on input/output errors
-
close
public void close() throws IOExceptionCloses the writer. This method must be called.- Throws:
IOException- on input/output errors
-
-