FilePartSource (HttpClient Library (Version 3.1))
Date: 2016-03-09

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, Mike Bowler

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FilePartSource(java.io.File file)` Constructor for FilePartSource.
    `FilePartSource(java.lang.String fileName, java.io.File file)` Constructor for FilePartSource.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.io.InputStream` | `createInputStream()` Return a new `FileInputStream` for the current filename.
    `java.lang.String` | `getFileName()` Return the current filename
    `long` | `getLength()` Return the length of the file

    - ### 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()

      Return the length of the file
      Specified by:
        `getLength` in interface `PartSource`
      Returns:
        the length of the file.
      See Also:
        `PartSource.getLength()`

    - #### getFileName

          public java.lang.String getFileName()

      Return the current filename
      Specified by:
        `getFileName` in interface `PartSource`
      Returns:
        the filename.
      See Also:
        `PartSource.getFileName()`

    - #### createInputStream

          public java.io.InputStream createInputStream()
                                                throws java.io.IOException

      Return a new `FileInputStream` for the current filename.
      Specified by:
        `createInputStream` in interface `PartSource`
      Returns:
        the new input stream.
      Throws:
        `java.io.IOException` - If an IO problem occurs.
      See Also:
        `PartSource.createInputStream()`

Copyright (c) 1999-2005 - Apache Software Foundation