org.apache.struts.upload

Class DiskFile

public class DiskFile extends Object implements FormFile

Deprecated: Use the Commons FileUpload based multipart handler instead. This class will be removed after Struts 1.2.

Field Summary
protected StringcontentType
The content type of the file
protected StringfileName
The name of the file
protected StringfilePath
The filepath to the temporary file
protected intfileSize
The size in bytes of the file
Constructor Summary
DiskFile(String filePath)
Method Summary
voiddestroy()
Delete the temporary file.
StringgetContentType()
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".
StringgetFileName()
Get the file name
StringgetFilePath()
Get the temporary file path for this form file
intgetFileSize()
Get the file size
InputStreamgetInputStream()
Returns a FileInputStream to the file
voidsetContentType(String contentType)
Set the content type
voidsetFileName(String filename)
Set the file name
voidsetFileSize(int fileSize)
Set the file size

Field Detail

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 Detail

DiskFile

public DiskFile(String filePath)

Method Detail

destroy

public void destroy()
Delete the temporary file.

getContentType

public String getContentType()
Get the content type

getFileData

public byte[] getFileData()
Attempt to read the temporary file and get it's data in byte array form. Tries to read the entire file (using a byte array the size of getFileSize()) at once, in one call to FileInputStream.read(byte[]). For buffered reading, see getFileData(int). Note that this method can be dangerous, and that the size of a file can cause an OutOfMemoryError quite easily. You should use getInputStream and do your own thing.

Throws: FileNotFoundException If the temp file no longer exists IOException if there is some sort of IO problem.

See Also: DiskFile

getFileData

public byte[] getFileData(int bufferSize)
Attempts to read a file n bytes at a time, n being equal to "bufferSize". Note that this method can be dangerous, and that the size of a file can cause an OutOfMemoryError quite easily. You should use getInputStream and do your own thing.

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

Throws: FileNotFoundException If the temp file no longer exists

getFileName

public String getFileName()
Get the file name

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

Returns: The size of this file in bytes

getInputStream

public InputStream getInputStream()
Returns a FileInputStream to the file

setContentType

public void setContentType(String contentType)
Set the content type

setFileName

public void setFileName(String filename)
Set the file name

setFileSize

public void setFileSize(int fileSize)
Set the file size

Parameters: fileSize The size of the file in bytes

Copyright B) 2000-2008 - The Apache Software Foundation