|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.benow.web.applet.upload.FolderUploadPost
public class FolderUploadPost
Modified from Vlad's excellent code to provide monitorable streaming. Stripped down.
Title: Client HTTP Request class
Description: this class helps to send POST HTTP requests with various form data, including files. Cookies can be added to be included in the request.
http://www.devx.com/Java/Article/17679/1954| Nested Class Summary | |
|---|---|
static class |
FolderUploadPost.BinaryParameter
Used to hold information about a binary part to submit in form. |
static interface |
FolderUploadPost.PostListener
|
| Constructor Summary | |
|---|---|
FolderUploadPost(java.lang.String urlString)
Creates a new multipart POST HTTP request for a specified URL string |
|
FolderUploadPost(java.net.URL url)
Creates a new multipart POST HTTP request for a specified URL |
|
FolderUploadPost(java.net.URLConnection connection)
Creates a new multipart POST HTTP request on a freshly opened URLConnection |
|
| Method Summary | |
|---|---|
void |
addListener(FolderUploadPost.PostListener listener)
|
void |
cancel()
|
protected void |
newline()
|
java.io.InputStream |
post()
posts the requests to the server, with all the cookies and parameters that were added |
protected static java.lang.String |
randomString()
|
void |
setCookie(java.lang.String name,
java.lang.String value)
adds a cookie to the requst |
void |
setCookies(java.util.Map cookies)
adds cookies to the request |
void |
setParameter(FolderUploadPost.BinaryParameter bp)
adds a file parameter to the request |
void |
setParameter(java.lang.String name,
java.io.File file)
adds a file parameter to the request |
void |
setParameter(java.lang.String name,
java.lang.Object object)
adds a parameter to the request; if the parameter is a File, the file is uploaded, otherwise the string value of the parameter is passed in the request |
void |
setParameter(java.lang.String name,
java.lang.String value)
adds a string parameter to the request |
void |
throttle()
|
protected void |
write(char c)
|
protected void |
write(java.lang.String s)
|
protected void |
writeln(java.lang.String s)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FolderUploadPost(java.net.URLConnection connection)
throws java.io.IOException
connection - an already open URL connection
java.io.IOException
public FolderUploadPost(java.net.URL url)
throws java.io.IOException
url - the URL to send request to
java.io.IOException
public FolderUploadPost(java.lang.String urlString)
throws java.io.IOException
urlString - the string representation of the URL to send request to
java.io.IOException| Method Detail |
|---|
protected void write(char c)
throws java.io.IOException
java.io.IOException
protected void write(java.lang.String s)
throws java.io.IOException
java.io.IOException
protected void newline()
throws java.io.IOException
java.io.IOException
protected void writeln(java.lang.String s)
throws java.io.IOException
java.io.IOExceptionprotected static java.lang.String randomString()
public void cancel()
public void setCookie(java.lang.String name,
java.lang.String value)
throws java.io.IOException
name - cookie namevalue - cookie value
java.io.IOException
public void setCookies(java.util.Map cookies)
throws java.io.IOException
cookies - the cookie "name-to-value" map
java.io.IOException
public void setParameter(java.lang.String name,
java.lang.String value)
throws java.io.IOException
name - parameter namevalue - parameter value
java.io.IOException
public void setParameter(FolderUploadPost.BinaryParameter bp)
throws java.io.IOException
name - parameter namefilename - the name of the fileis - input stream to read the contents of the file from
java.io.IOException
public void setParameter(java.lang.String name,
java.io.File file)
throws java.io.IOException
name - parameter namefile - the file to upload
java.io.IOException
public void setParameter(java.lang.String name,
java.lang.Object object)
throws java.io.IOException
name - parameter nameobject - parameter value, a File or anything else that can be stringified
java.io.IOException
public java.io.InputStream post()
throws java.io.IOException
java.io.IOExceptionpublic void addListener(FolderUploadPost.PostListener listener)
public void throttle()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||