javax.servlet.http

## Interface Part

    public interface Part

This class represents a part as uploaded to the server as part of a `multipart/form-data` request body. The part may represent either an uploaded file or form data.

Since:
  Servlet 3.0

### Method Summary

All Methods Instance Methods Abstract Methods
`void` `delete()` Deletes the underlying storage for a part, including deleting any associated temporary disk file.
`java.lang.String` `getContentType()` Obtain the content type passed by the browser or `null` if not defined.
`java.lang.String` `getHeader(java.lang.String name)` Obtains the value of the specified part header as a String.
`java.util.Collection<java.lang.String>` `getHeaderNames()` Returns a Collection of all the header names provided for this part.
`java.util.Collection<java.lang.String>` `getHeaders(java.lang.String name)` Obtain all the values of the specified part header.
`java.io.InputStream` `getInputStream()` Obtain an `InputStream` that can be used to retrieve the contents of the file.
`java.lang.String` `getName()` Obtain the name of the field in the multipart form corresponding to this part.
`long` `getSize()` Obtain the size of this part.
`void` `write(java.lang.String fileName)` A convenience method to write an uploaded part to disk.

### Method Detail

#### getInputStream

    java.io.InputStream getInputStream()
                                throws java.io.IOException

Obtain an `InputStream` that can be used to retrieve the contents of the file.

Throws:
  `java.io.IOException`

#### getContentType

    java.lang.String getContentType()

Obtain the content type passed by the browser or `null` if not defined.

#### getName

    java.lang.String getName()

Obtain the name of the field in the multipart form corresponding to this part.

#### getSize

    long getSize()

Obtain the size of this part.

#### write

    void write(java.lang.String fileName)
        throws java.io.IOException

A convenience method to write an uploaded part to disk. The client code is not concerned with whether or not the part is stored in memory, or on disk in a temporary location. They just want to write the uploaded part to a file. This method is not guaranteed to succeed if called more than once for the same part. This allows a particular implementation to use, for example, file renaming, where possible, rather than copying all of the underlying data, thus gaining a significant performance benefit.

Parameters:
  `fileName` - The location into which the uploaded part should be stored. Relative locations are relative to `MultipartConfigElement.getLocation()`
Throws:
  `java.io.IOException`

#### delete

    void delete()
         throws java.io.IOException

Deletes the underlying storage for a part, including deleting any associated temporary disk file. Although the container will delete this storage automatically this method can be used to ensure that this is done at an earlier time, thus preserving system resources.

Containers are only required to delete the associated storage when the Part instance is garbage collected. Apache Tomcat will delete the associated storage when the associated request has finished processing. Behaviour of other containers may be different.

Throws:
  `java.io.IOException`

#### getHeader

    java.lang.String getHeader(java.lang.String name)

Obtains the value of the specified part header as a String. If there are multiple headers with the same name, this method returns the first header in the part. The header name is case insensitive.

Parameters:
  `name` - Header name
Returns:
  The header value or `null` if the header is not present

#### getHeaders

    java.util.Collection<java.lang.String> getHeaders(java.lang.String name)

Obtain all the values of the specified part header. If the part did not include any headers of the specified name, this method returns an empty Collection. The header name is case insensitive.

#### getHeaderNames

    java.util.Collection<java.lang.String> getHeaderNames()

Returns a Collection of all the header names provided for this part.