|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.struts.upload.DiskFile
Field Summary | |
protected java.lang.String |
contentType
The content type of the file |
protected java.lang.String |
fileName
The name of the file |
protected java.lang.String |
filePath
The filepath to the temporary file |
protected int |
fileSize
The size in bytes of the file |
Constructor Summary | |
DiskFile(java.lang.String filePath)
|
Method Summary | |
void |
destroy()
Delete the temporary file. |
java.lang.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". |
java.lang.String |
getFileName()
Get the file name |
java.lang.String |
getFilePath()
Get the temporary file path for this form file |
int |
getFileSize()
Get the file size |
java.io.InputStream |
getInputStream()
Returns a FileInputStream to the file |
void |
setContentType(java.lang.String contentType)
Set the content type |
void |
setFileName(java.lang.String filename)
Set the file name |
void |
setFileSize(int fileSize)
Set the file size |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.String filePath
protected java.lang.String contentType
protected int fileSize
protected java.lang.String fileName
Constructor Detail |
public DiskFile(java.lang.String filePath)
Method Detail |
public byte[] getFileData() throws java.io.FileNotFoundException, java.io.IOException
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
java.io.FileNotFoundException
- If the temp file no longer exists
java.io.IOException
- if there is some sort of IO problem.getFileData(int)
public byte[] getFileData(int bufferSize) throws java.io.FileNotFoundException, java.io.IOException
getInputStream
and do your own thing.
bufferSize
- The size in bytes that are read from the file at a time
java.io.FileNotFoundException
- If the temp file no longer exists
java.io.IOException
public void destroy()
destroy
in interface FormFile
public java.lang.String getFilePath()
public void setFileName(java.lang.String filename)
setFileName
in interface FormFile
filename
- The base file name.public void setContentType(java.lang.String contentType)
setContentType
in interface FormFile
contentType
- The content type for the file.public void setFileSize(int fileSize)
setFileSize
in interface FormFile
fileSize
- The size of the file in bytespublic java.lang.String getFileName()
getFileName
in interface FormFile
public java.lang.String getContentType()
getContentType
in interface FormFile
public int getFileSize()
getFileSize
in interface FormFile
public java.io.InputStream getInputStream() throws java.io.FileNotFoundException, java.io.IOException
getInputStream
in interface FormFile
java.io.IOException
- if an error occurred while reading the
file.
java.io.FileNotFoundException
- if the uploaded file is not found.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |