org.apache.struts.upload

Interface FormFile

Known Implementing Classes:
CommonsMultipartRequestHandler.CommonsFormFile, DiskFile

public interface FormFile

This interface represents a file that has been uploaded by a client. It is the only interface or class in upload package which is typically referenced directly by a Struts application.

Method Summary

void
destroy()
Destroys all content for the uploaded file, including any underlying data files.
String
getContentType()
Returns the content type for this file.
byte[]
getFileData()
Returns the data for the entire file as byte array.
String
getFileName()
Returns the file name of this file.
int
getFileSize()
Returns the size of this file.
InputStream
getInputStream()
Returns an input stream for this file.
void
setContentType(String contentType)
Sets the content type for this file.
void
setFileName(String fileName)
Sets the file name of this file.
void
setFileSize(int fileSize)
Sets the file size.

Method Details

destroy

public void destroy()
Destroys all content for the uploaded file, including any underlying data files.

getContentType

public String getContentType()
Returns the content type for this file.
Returns:
A String representing content type.

getFileData

public byte[] getFileData()
            throws FileNotFoundException,
                   IOException
Returns:
The file data as a byte array.

getFileName

public String getFileName()
Returns the file name of this file. This is the base name of the file, as supplied by the user when the file was uploaded.
Returns:
The base file name.

getFileSize

public int getFileSize()
Returns the size of this file.
Returns:
The size of the file, in bytes.

getInputStream

public InputStream getInputStream()
            throws FileNotFoundException,
                   IOException
Returns an input stream for this file. The caller must close the stream when it is no longer needed.

setContentType

public void setContentType(String contentType)
Sets the content type for this file.
Parameters:
contentType - The content type for the file.

setFileName

public void setFileName(String fileName)
Sets the file name of this file.
Parameters:
fileName - The base file name.

setFileSize

public void setFileSize(int fileSize)
Sets the file size.
Parameters:
fileSize - The size of the file, in bytes,

Copyright B) 2000-2007 - The Apache Software Foundation