Class FileParameter
- java.lang.Object
-
- com.aspectran.core.activity.request.parameter.FileParameter
-
- Direct Known Subclasses:
CommonsMultipartFileParameter,MemoryMultipartFileParameter
public class FileParameter extends java.lang.ObjectThe Class FileParameter.Created: 2008. 04. 11 PM 4:19:40
-
-
Field Summary
Fields Modifier and Type Field Description protected java.io.FilesavedFile
-
Constructor Summary
Constructors Modifier Constructor Description protectedFileParameter()Instantiates a new FileParameter.FileParameter(java.io.File file)Instantiates a new FileParameter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete()Delete a file.byte[]getBytes()Returns the contents of the file in a byte array.java.lang.StringgetContentType()Gets the the content type of the file.java.io.FilegetFile()java.lang.StringgetFileName()Gets the actual name of the file uploaded.longgetFileSize()Gets the size of the file uploaded.java.io.InputStreamgetInputStream()Returns anInputStreamobject of the file.java.io.FilegetSavedFile()Returns the saved file.booleanisRefused()Checks if the file is refused.voidrelease()Sets the access permission that allow write operations on the file associated with this FileParameter.voidrollback()If the saved file exists, delete it.java.io.FilesaveAs(java.io.File destFile)Save an uploaded file as a given destination file.java.io.FilesaveAs(java.io.File destFile, boolean overwrite)Save an file as a given destination file.voidsetRefused(boolean refused)Sets whether the refused file.java.lang.StringtoString()
-
-
-
Method Detail
-
getFile
public java.io.File getFile()
-
getFileName
public java.lang.String getFileName()
Gets the actual name of the file uploaded.- Returns:
- the actual name of the file uploaded
-
getFileSize
public long getFileSize()
Gets the size of the file uploaded.- Returns:
- the size of the file uploaded
-
getContentType
public java.lang.String getContentType()
Gets the the content type of the file.- Returns:
- the content type of the file
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOExceptionReturns anInputStreamobject of the file.- Returns:
- an
OutputStreamthat can be used for storing the contents of the file. - Throws:
java.io.IOException- if an I/O error has occurred
-
getBytes
public byte[] getBytes() throws java.io.IOExceptionReturns the contents of the file in a byte array. Can not use a large array of memory than the JVM Heap deal.- Returns:
- a byte array
- Throws:
java.io.IOException- if an I/O error has occurred
-
isRefused
public boolean isRefused()
Checks if the file is refused.- Returns:
- true if the file is refused; false otherwise
-
setRefused
public void setRefused(boolean refused)
Sets whether the refused file.- Parameters:
refused- whether the file is refused or not
-
saveAs
public java.io.File saveAs(java.io.File destFile) throws java.io.IOExceptionSave an uploaded file as a given destination file. If the file already exists in directory the save with a different name.- Parameters:
destFile- the destination file- Returns:
- a saved file
- Throws:
java.io.IOException- if an I/O error has occurred
-
saveAs
public java.io.File saveAs(java.io.File destFile, boolean overwrite) throws java.io.IOExceptionSave an file as a given destination file.- Parameters:
destFile- the destination fileoverwrite- whether to overwrite if it already exists- Returns:
- a saved file
- Throws:
java.io.IOException- if an I/O error has occurred
-
getSavedFile
public java.io.File getSavedFile()
Returns the saved file.- Returns:
- the saved file
-
delete
public void delete()
Delete a file.
-
rollback
public void rollback()
If the saved file exists, delete it.
-
release
public void release()
Sets the access permission that allow write operations on the file associated with this FileParameter.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-