Professional Documents
Culture Documents
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD
javax.servlet.http
Interface Part
This class represents a part or form item that was received within a multipart/form-
data POST request.
Since:
Servlet 3.0
Method Summary
void delete()
Deletes the underlying storage for a file item, including
deleting any associated temporary disk file.
String getContentType()
Gets the content type of this part.
String getHeader(String name)
Returns the value of the specified mime header as a
String.
Collection<String> getHeaderNames()
Gets the header names of this Part.
Collection<String> getHeaders(String name)
Gets the values of the Part header with the given name.
InputStream getInputStream()
Gets the content of this part as an InputStream
1 of 5 1/23/19, 8:35 PM
Part (Java(TM) EE 7 Specification APIs) https://docs.oracle.com/javaee/7/api/javax/servlet/...
String getName()
Gets the name of this part
long getSize()
Returns the size of this fille.
String getSubmittedFileName()
Gets the file name specified by the client
void write(String fileName)
A convenience method to write this uploaded item to disk.
Method Detail
getInputStream
InputStream getInputStream()
throws IOException
getContentType
String getContentType()
getName
String getName()
2 of 5 1/23/19, 8:35 PM
Part (Java(TM) EE 7 Specification APIs) https://docs.oracle.com/javaee/7/api/javax/servlet/...
Returns:
The name of this part as a String
getSubmittedFileName
String getSubmittedFileName()
getSize
long getSize()
write
void write(String fileName)
throws IOException
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 name of the file to which the stream will be written.
The file is created relative to the location as specified in the
MultipartConfig
Throws:
IOException - if an error occurs.
3 of 5 1/23/19, 8:35 PM
Part (Java(TM) EE 7 Specification APIs) https://docs.oracle.com/javaee/7/api/javax/servlet/...
delete
void delete()
throws IOException
Deletes the underlying storage for a file item, including deleting any associated
temporary disk file.
Throws:
IOException - if an error occurs.
getHeader
String getHeader(String name)
Returns the value of the specified mime header as a String. If the Part did not
include a header of the specified name, this method returns null. If there are
multiple headers with the same name, this method returns the first header in the
part. The header name is case insensitive. You can use this method with any
request header.
Parameters:
name - a String specifying the header name
Returns:
a String containing the value of the requested header, or null if the
part does not have a header of that name
getHeaders
Collection<String> getHeaders(String name)
Gets the values of the Part header with the given name.
Any changes to the returned Collection must not affect this Part.
Parameters:
name - the header name whose values to return
Returns:
a (possibly empty) Collection of the values of the header with the
given name
4 of 5 1/23/19, 8:35 PM
Part (Java(TM) EE 7 Specification APIs) https://docs.oracle.com/javaee/7/api/javax/servlet/...
getHeaderNames
Collection<String> getHeaderNames()
Some servlet containers do not allow servlets to access headers using this
method, in which case this method returns null
Any changes to the returned Collection must not affect this Part.
Returns:
a (possibly empty) Collection of the header names of this Part
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD
Copyright © 1996-2015, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.
5 of 5 1/23/19, 8:35 PM