org.apache.struts.upload

Class DiskFile

Implemented Interfaces:
FormFile

public class DiskFile
extends java.lang.Object
implements FormFile

Field Summary

protected String
contentType
The content type of the file
protected String
fileName
The name of the file
protected String
filePath
The filepath to the temporary file
protected int
fileSize
The size in bytes of the file

Constructor Summary

DiskFile(String filePath)

Method Summary

void
destroy()
Delete the temporary file.
String
getContentType()
Get the content type
byte[]
getFileData()
Attempt to read the temporary file and get it's data in byte array form.
byte[]
getFileData(int bufferSize)
Attempts to read a file n bytes at a time, n being equal to "bufferSize".
String
getFileName()
Get the file name
String
getFilePath()
Get the temporary file path for this form file
int
getFileSize()
Get the file size
InputStream
getInputStream()
Returns a FileInputStream to the file
void
setContentType(String contentType)
Set the content type
void
setFileName(String filename)
Set the file name
void
setFileSize(int fileSize)
Set the file size

Field Details

contentType

protected String contentType
The content type of the file


fileName

protected String fileName
The name of the file


filePath

protected String filePath
The filepath to the temporary file


fileSize

protected int fileSize
The size in bytes of the file

Constructor Details

DiskFile

public DiskFile(String filePath)

Method Details

destroy

public void destroy()
Delete the temporary file.
Specified by:
destroy in interface FormFile


getContentType

public String getContentType()
Get the content type
Specified by:
getContentType in interface FormFile


getFileData

public byte[] getFileData()
            throws FileNotFoundException,
                   IOException
Specified by:
getFileData in interface FormFile

See Also:
getFileData(int)


getFileData

public byte[] getFileData(int bufferSize)
            throws FileNotFoundException,
                   IOException

Parameters:
bufferSize - The size in bytes that are read from the file at a time


getFileName

public String getFileName()
Get the file name
Specified by:
getFileName in interface FormFile


getFilePath

public String getFilePath()
Get the temporary file path for this form file

Returns:
A filepath to the temporary file


getFileSize

public int getFileSize()
Get the file size
Specified by:
getFileSize in interface FormFile

Returns:
The size of this file in bytes


getInputStream

public InputStream getInputStream()
            throws FileNotFoundException,
                   IOException
Returns a FileInputStream to the file
Specified by:
getInputStream in interface FormFile


setContentType

public void setContentType(String contentType)
Set the content type
Specified by:
setContentType in interface FormFile


setFileName

public void setFileName(String filename)
Set the file name
Specified by:
setFileName in interface FormFile


setFileSize

public void setFileSize(int fileSize)
Set the file size
Specified by:
setFileSize in interface FormFile

Parameters:
fileSize - The size of the file in bytes


Copyright B) 2000-2005 - Apache Software Foundation