All Packages Class Hierarchy This Package Previous Next Index
Class nl.nmg.servlet.UploadedFile
java.lang.Object
|
+----nl.nmg.servlet.UploadedFile
- public class UploadedFile
- extends Object
The UploadedFile class represents files uploaded with a multipart/form-data
form. The files are stored either in memory or on disk. UploadedFile objects
are returned by ExtendedRequest.getFileParameter().
- See Also:
- getFileParameter, getFileParameterValues
-
deleteTemporaryFile()
- Deletes any temporary file associated with this uploaded file.
-
getBytes()
- Returns the contents as a byte array.
-
getContentFilename()
- Returns the client-side filename of the uploaded file or
null
if unknown.
-
getContentFullFilename()
- Returns the full client-side filename of the uploaded file as
it was sent to the server or
null
if unknown.
-
getContentLength()
- Returns the length of the file.
-
getContentType()
- Returns the content-type of the file or
null
if unknown.
-
getInputStream()
- Creates an
InputStream
that can be used to read the
contents of the uploaded file.
-
getReader()
- Creates a
Reader
that can be used to read the
contents of the uploaded file.
-
getTemporaryFile()
- Returns a handle to the temporary file that stores the
uploaded file.
-
toString()
- Returns the full client-side filename of the uploaded file.
getContentType
public String getContentType()
- Returns the content-type of the file or
null
if unknown.
Some browsers don't send content-types for plain text files.
- Returns:
- the content-type
getContentLength
public int getContentLength()
- Returns the length of the file. This is the actual length, not
the value of a header.
- Returns:
- the length
getContentFilename
public String getContentFilename()
- Returns the client-side filename of the uploaded file or
null
if unknown. If the filename contains
backslashes or forward slashes, only the part
after the last slash is returned.
- Returns:
- the useful part of the client-side filename
getContentFullFilename
public String getContentFullFilename()
- Returns the full client-side filename of the uploaded file as
it was sent to the server or
null
if unknown.
- Returns:
- the full client-side filename
getInputStream
public InputStream getInputStream() throws IOException
- Creates an
InputStream
that can be used to read the
contents of the uploaded file.
- Returns:
- an
InputStream
for the contents
getReader
public Reader getReader() throws IOException
- Creates a
Reader
that can be used to read the
contents of the uploaded file.
- Returns:
- a
Reader
for the contents
getBytes
public byte[] getBytes()
- Returns the contents as a byte array. If the uploaded file
has been stored in a temporary file, the file is read to
get the complete contents.
- Returns:
- the contents of the uploaded file
- Throws: IllegalStateException
- when an IOException occurred
while reading the temporary file.
getTemporaryFile
public File getTemporaryFile()
- Returns a handle to the temporary file that stores the
uploaded file. This file may disappear when
ExtendedRequest.deleteTemporaryFiles() or UploadedFile.deleteTemporaryFile()
is called, so use with care.
- Throws: IllegalStateException
- when the contents
have been saved in memory.
deleteTemporaryFile
public void deleteTemporaryFile()
- Deletes any temporary file associated with this uploaded file.
When called a second time or for an uploaded file whose contents
are stored in memory, nothing is done.
toString
public String toString()
- Returns the full client-side filename of the uploaded file.
- Returns:
- the full client-side filename of the uploaded file
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index