org.apache.struts.upload
Class DiskFile
java.lang.Object
org.apache.struts.upload.DiskFile
- FormFile
public class DiskFile
extends java.lang.Object
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
|
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
|
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
DiskFile
public DiskFile(String filePath)
destroy
public void destroy()
Delete the temporary file.
- destroy in interface FormFile
getFileData
public byte[] getFileData()
throws FileNotFoundException,
IOException
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.
- getFileData in interface FormFile
getFileData
public byte[] getFileData(int bufferSize)
throws FileNotFoundException,
IOException
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.
bufferSize
- The size in bytes that are read from the file at a time
getFilePath
public String getFilePath()
Get the temporary file path for this form file
- A filepath to the temporary file
getFileSize
public int getFileSize()
Get the file size
- getFileSize in interface FormFile
- The size of this file in bytes
getInputStream
public InputStream getInputStream()
throws FileNotFoundException,
IOException
Returns a FileInputStream to the file
- getInputStream in interface FormFile
setContentType
public void setContentType(String contentType)
Set the content type
- setContentType in interface FormFile
setFileName
public void setFileName(String filename)
Set the file name
- setFileName in interface FormFile
setFileSize
public void setFileSize(int fileSize)
Set the file size
- setFileSize in interface FormFile
fileSize
- The size of the file in bytes
Copyright B) 2000-2007 - The Apache Software Foundation