public interface FileItem extends FileItemStream
This class represents a file or form item that was received within a
multipart/form-data POST request.
| 限定符和类型 | 方法和说明 |
|---|---|
void |
deleteOrSkip()
Deletes the underlying storage for a file item, including deleting any
associated temporary disk file.
|
byte[] |
get()
Returns the contents of the file item as an array of bytes.
|
long |
getSize()
Returns the size of the file item.
|
String |
getString()
Returns the contents of the file item as a String, using the default
character encoding.
|
String |
getString(String encoding)
Returns the contents of the file item as a String, using the specified
encoding.
|
void |
writeTo(File file)
A convenience method to write an uploaded item to disk.
|
void |
writeTo(OutputStream outStream)
A convenience method to write an uploaded item to disk.
|
getContentType, getFieldName, getHeaders, getName, isFormField, openStreamlong getSize()
void writeTo(File file) throws IOException
This method is not guaranteed to succeed if called more than once for the same item. This allows a particular implementation to use, for example, file renaming, where possible, rather than copying all of the underlying data, thus gaining a significant performance benefit.
file - The File into which the uploaded item should be stored.Exception - if an error occurs.IOExceptionvoid writeTo(OutputStream outStream) throws IOException
This method is not guaranteed to succeed if called more than once for the same item. This allows a particular implementation to use, for example, file renaming, where possible, rather than copying all of the underlying data, thus gaining a significant performance benefit.
outStream - The OutputStream into which the uploaded item should be stored.Exception - if an error occurs.IOExceptionvoid deleteOrSkip()
FileItem instance is garbage
collected, this method can be used to ensure that this is done at an
earlier time, thus preserving system resources.byte[] get()
throws IOException
IOExceptionString getString(String encoding) throws IOException
get() to retrieve the
contents of the item.encoding - The character encoding to use.UnsupportedEncodingException - if the requested character encoding is not available.IOExceptionString getString() throws IOException
get() to retrieve the
contents of the item.IOException