Class FileParameter
- java.lang.Object
-
- com.aspectran.core.activity.request.FileParameter
-
- Direct Known Subclasses:
CommonsMultipartFileParameter
,MemoryMultipartFileParameter
public class FileParameter extends java.lang.Object
The Class FileParameter.Created: 2008. 04. 11 PM 4:19:40
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FileParameter()
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 void
delete()
Delete a file.protected java.io.File
determineDestinationFile(java.io.File destFile, boolean overwrite)
byte[]
getBytes()
Returns the contents of the file in a byte array.java.lang.String
getContentType()
Gets the the content type of the file.java.io.File
getFile()
java.lang.String
getFileName()
Gets the actual name of the file uploaded.long
getFileSize()
Gets the size of the file uploaded.java.io.InputStream
getInputStream()
Returns anInputStream
object of the file.java.io.File
getSavedFile()
Returns the saved file.boolean
isRefused()
Checks if the file is refused.void
release()
Sets the access permission that allow write operations on the file associated with this FileParameter.protected void
releaseSavedFile()
java.io.File
renameTo(java.io.File destFile)
java.io.File
renameTo(java.io.File destFile, boolean overwrite)
void
rollback()
If the saved file exists, delete it.java.io.File
saveAs(java.io.File destFile)
Save an uploaded file as a given destination file.java.io.File
saveAs(java.io.File destFile, boolean overwrite)
Save an file as a given destination file.void
setRefused(boolean refused)
Sets whether the refused file.protected void
setSavedFile(java.io.File savedFile)
java.lang.String
toString()
-
-
-
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.IOException
Returns anInputStream
object of the file.- Returns:
- an
OutputStream
that 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.IOException
Returns 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.IOException
Save 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.IOException
Save 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
-
renameTo
public java.io.File renameTo(java.io.File destFile) throws java.io.IOException
- Throws:
java.io.IOException
-
renameTo
public java.io.File renameTo(java.io.File destFile, boolean overwrite) throws java.io.IOException
- Throws:
java.io.IOException
-
determineDestinationFile
protected java.io.File determineDestinationFile(java.io.File destFile, boolean overwrite) throws java.io.IOException
- Throws:
java.io.IOException
-
getSavedFile
public java.io.File getSavedFile()
Returns the saved file.- Returns:
- the saved file
-
setSavedFile
protected void setSavedFile(java.io.File savedFile)
-
releaseSavedFile
protected void releaseSavedFile()
-
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:
toString
in classjava.lang.Object
-
-