All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.oreilly.servlet.multipart.FilePart

java.lang.Object
   |
   +----com.oreilly.servlet.multipart.Part
           |
           +----com.oreilly.servlet.multipart.FilePart

public class FilePart
extends Part
A FilePart is an upload part which represents a INPUT TYPE="file" form parameter.

Version:
1.2, 2001/01/22, getFilePath() addition thanks to Stefan Eissing
Author:
Geoff Soutter

Method Index

 o getContentType()
Returns the content type of the file data contained within.
 o getFileName()
Returns the name that the file was stored with on the remote system, or null if the user didn't enter a file to be uploaded.
 o getFilePath()
Returns the full path and name of the file on the remote system, or null if the user didn't enter a file to be uploaded.
 o getInputStream()
Returns an input stream which contains the contents of the file supplied.
 o isFile()
Returns true to indicate this part is a file.
 o writeTo(File)
Write this file part to a file or directory.
 o writeTo(OutputStream)
Write this file part to the given output stream.

Methods

 o getFileName
 public String getFileName()
Returns the name that the file was stored with on the remote system, or null if the user didn't enter a file to be uploaded. Note: this is not the same as the name of the form parameter used to transmit the file; that is available from the getName method.

Returns:
name of file uploaded or null.
See Also:
getName
 o getFilePath
 public String getFilePath()
Returns the full path and name of the file on the remote system, or null if the user didn't enter a file to be uploaded. If path information was not supplied by the remote system, this method will return the same as getFileName().

Returns:
path of file uploaded or null.
See Also:
getName
 o getContentType
 public String getContentType()
Returns the content type of the file data contained within.

Returns:
content type of the file data.
 o getInputStream
 public InputStream getInputStream()
Returns an input stream which contains the contents of the file supplied. If the user didn't enter a file to upload there will be 0 bytes in the input stream. It's important to read the contents of the InputStream immediately and in full before proceeding to process the next part. The contents will otherwise be lost on moving to the next part.

Returns:
an input stream containing contents of file.
 o writeTo
 public long writeTo(File fileOrDirectory) throws IOException
Write this file part to a file or directory. If the user supplied a file, we write it to that file, and if they supplied a directory, we write it to that directory with the filename that accompanied it. If this part doesn't contain a file this method does nothing.

Returns:
number of bytes written
Throws: IOException
if an input or output exception has occurred.
 o writeTo
 public long writeTo(OutputStream out) throws IOException
Write this file part to the given output stream. If this part doesn't contain a file this method does nothing.

Returns:
number of bytes written.
Throws: IOException
if an input or output exception has occurred.
 o isFile
 public boolean isFile()
Returns true to indicate this part is a file.

Returns:
true.
Overrides:
isFile in class Part

All Packages  Class Hierarchy  This Package  Previous  Next  Index