Class FilePartSource
- java.lang.Object
-
- org.apache.commons.httpclient.methods.multipart.FilePartSource
-
- All Implemented Interfaces:
PartSource
public class FilePartSource extends Object implements PartSource
A PartSource that reads from a File.- Since:
- 2.0
- Author:
- Michael Becke, Mark Diggory, Mike Bowler
-
-
Constructor Summary
Constructors Constructor Description FilePartSource(File file)
Constructor for FilePartSource.FilePartSource(String fileName, File file)
Constructor for FilePartSource.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStream
createInputStream()
Return a newFileInputStream
for the current filename.String
getFileName()
Return the current filenamelong
getLength()
Return the length of the file
-
-
-
Constructor Detail
-
FilePartSource
public FilePartSource(File file) throws FileNotFoundException
Constructor for FilePartSource.- Parameters:
file
- the FilePart source File.- Throws:
FileNotFoundException
- if the file does not exist or cannot be read
-
FilePartSource
public FilePartSource(String fileName, File file) throws FileNotFoundException
Constructor for FilePartSource.- Parameters:
fileName
- the file name of the FilePartfile
- the source File for the FilePart- Throws:
FileNotFoundException
- if the file does not exist or cannot be read
-
-
Method Detail
-
getLength
public long getLength()
Return the length of the file- Specified by:
getLength
in interfacePartSource
- Returns:
- the length of the file.
- See Also:
PartSource.getLength()
-
getFileName
public String getFileName()
Return the current filename- Specified by:
getFileName
in interfacePartSource
- Returns:
- the filename.
- See Also:
PartSource.getFileName()
-
createInputStream
public InputStream createInputStream() throws IOException
Return a newFileInputStream
for the current filename.- Specified by:
createInputStream
in interfacePartSource
- Returns:
- the new input stream.
- Throws:
IOException
- If an IO problem occurs.- See Also:
PartSource.createInputStream()
-
-