public class FormUtility
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
BUFFER_SIZE
The size of the read buffer.
|
static java.lang.String |
ENCODE
The charset to use for URL encoding.
|
static int |
RANDOM_LENGTH
The length of random string to create for multipart.
|
| Constructor and Description |
|---|
FormUtility(java.io.OutputStream os,
java.lang.String boundary)
Prepare to access either a regular, or multipart, form.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(java.lang.String name,
java.io.File file)
Add a file to a multipart form.
|
void |
add(java.lang.String name,
java.lang.String value)
Add a regular text field to either a regular or multipart form.
|
void |
complete()
Complete the building of the form.
|
static java.lang.String |
getBoundary()
Generate a boundary for a multipart form.
|
static java.util.Map<java.lang.String,java.lang.String> |
parse(java.lang.String form)
Parse a URL query string.
|
protected static java.lang.String |
randomString()
Generate a random string, of a specified length.
|
protected void |
writeln(java.lang.String str)
Write a string, with a carriage return and linefeed.
|
public static final java.lang.String ENCODE
public static final int BUFFER_SIZE
public static final int RANDOM_LENGTH
public FormUtility(java.io.OutputStream os,
java.lang.String boundary)
os - The stream to output to.boundary - The boundary to be used, or null if this is not a multipart
form.public static java.lang.String getBoundary()
public static java.util.Map<java.lang.String,java.lang.String> parse(java.lang.String form)
form - The query string to parse.protected static java.lang.String randomString()
public void add(java.lang.String name,
java.io.File file)
name - The field name.file - The file to attach.public void add(java.lang.String name,
java.lang.String value)
name - The name of the field.value - The value of the field.public void complete()
protected void writeln(java.lang.String str)
str - The string to write.