org.apache.commons.httpclient.methods.multipart
Class FilePartSource

java.lang.Object
  |
  +--org.apache.commons.httpclient.methods.multipart.FilePartSource
All Implemented Interfaces:
PartSource

public class FilePartSource
extends java.lang.Object
implements PartSource

A PartSource that reads from a File.

Since:
2.0
Author:
Michael Becke, Mark Diggory

Constructor Summary
FilePartSource(java.io.File file)
          Constructor for FilePartSource.
FilePartSource(java.lang.String fileName, java.io.File file)
          Constructor for FilePartSource.
 
Method Summary
 java.io.InputStream createInputStream()
          Gets a new InputStream for reading this source.
 java.lang.String getFileName()
          Gets the name of the file this source represents.
 long getLength()
          Gets the number of bytes contained in this source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilePartSource

public FilePartSource(java.io.File file)
               throws java.io.FileNotFoundException
Constructor for FilePartSource.

Parameters:
file - the FilePart source File.
Throws:
java.io.FileNotFoundException - if the file does not exist or cannot be read

FilePartSource

public FilePartSource(java.lang.String fileName,
                      java.io.File file)
               throws java.io.FileNotFoundException
Constructor for FilePartSource.

Parameters:
fileName - the file name of the FilePart
file - the source File for the FilePart
Throws:
java.io.FileNotFoundException - if the file does not exist or cannot be read
Method Detail

getLength

public long getLength()
Description copied from interface: PartSource
Gets the number of bytes contained in this source.

Specified by:
getLength in interface PartSource
Returns:
a value >= 0
See Also:
PartSource.getLength()

getFileName

public java.lang.String getFileName()
Description copied from interface: PartSource
Gets the name of the file this source represents.

Specified by:
getFileName in interface PartSource
Returns:
the fileName used for posting a MultiPart file part
See Also:
PartSource.getFileName()

createInputStream

public java.io.InputStream createInputStream()
                                      throws java.io.IOException
Description copied from interface: PartSource
Gets a new InputStream for reading this source. This method can be called more than once and should therefore return a new stream every time.

Specified by:
createInputStream in interface PartSource
Returns:
a new InputStream
Throws:
java.io.IOException - if an error occurs when creating the InputStream
See Also:
PartSource.createInputStream()


Copyright © 2001-2003 Apache Software Foundation. All Rights Reserved.