org.apache.commons.httpclient.methods.multipart

Class FilePartSource

Implemented Interfaces:
PartSource

public class FilePartSource
extends java.lang.Object
implements PartSource

A PartSource that reads from a File.
Authors:
Michael Becke
Mark Diggory
Mike Bowler
Since:
2.0

Constructor Summary

FilePartSource(File file)
Constructor for FilePartSource.
FilePartSource(String fileName, File file)
Constructor for FilePartSource.

Method Summary

InputStream
createInputStream()
Return a new FileInputStream for the current filename.
String
getFileName()
Return the current filename
long
getLength()
Return the length of the file

Constructor Details

FilePartSource

public FilePartSource(File file)
            throws FileNotFoundException
Constructor for FilePartSource.
Parameters:
file - the FilePart source File.

FilePartSource

public FilePartSource(String fileName,
                      File file)
            throws FileNotFoundException
Constructor for FilePartSource.
Parameters:
fileName - the file name of the FilePart
file - the source File for the FilePart

Method Details

createInputStream

public InputStream createInputStream()
            throws IOException
Return a new FileInputStream for the current filename.
Specified by:
createInputStream in interface PartSource
Returns:
the new input stream.

getFileName

public String getFileName()
Return the current filename
Specified by:
getFileName in interface PartSource
Returns:
the filename.

getLength

public long getLength()
Return the length of the file
Specified by:
getLength in interface PartSource
Returns:
the length of the file.

Copyright (c) 1999-2005 - Apache Software Foundation