-
public interface PartThis class represents a part or form item that was received within a
multipart/form-dataPOST request.- Since:
- Servlet 3.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description voiddelete()Deletes the underlying storage for a file item, including deleting any associated temporary disk file.StringgetContentType()Gets the content type of this part.StringgetHeader(String name)Returns the value of the specified mime header as aString.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.InputStreamgetInputStream()Gets the content of this part as an InputStreamStringgetName()Gets the name of this partlonggetSize()Returns the size of this fille.StringgetSubmittedFileName()Gets the file name specified by the clientvoidwrite(String fileName)A convenience method to write this uploaded item to disk.
-
-
-
Method Detail
-
getInputStream
InputStream getInputStream() throws IOException
Gets the content of this part as an InputStream- Returns:
- The content of this part as an InputStream
- Throws:
IOException- If an error occurs in retrieving the contet as an InputStream
-
getContentType
String getContentType()
Gets the content type of this part.- Returns:
- The content type of this part.
-
getName
String getName()
Gets the name of this part- Returns:
- The name of this part as a String
-
getSubmittedFileName
String getSubmittedFileName()
Gets the file name specified by the client- Returns:
- the submitted file name
- Since:
- Servlet 3.1
-
getSize
long getSize()
Returns the size of this fille.- Returns:
- a
longspecifying the size of this part, in bytes.
-
write
void write(String fileName) throws IOException
A convenience method to write this uploaded item to disk.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.
-
delete
void delete() throws IOExceptionDeletes 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 aString. If the Part did not include a header of the specified name, this method returnsnull. 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- aStringspecifying the header name- Returns:
- a
Stringcontaining the value of the requested header, ornullif 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
Collectionmust not affect thisPart.Part header names are case insensitive.
- Parameters:
name- the header name whose values to return- Returns:
- a (possibly empty)
Collectionof the values of the header with the given name
-
getHeaderNames
Collection<String> getHeaderNames()
Gets the header names of this Part.Some servlet containers do not allow servlets to access headers using this method, in which case this method returns
nullAny changes to the returned
Collectionmust not affect thisPart.- Returns:
- a (possibly empty)
Collectionof the header names of this Part
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
07/10/2025 01:51:47 Cette version de la page est en cache (à la date du 07/10/2025 01:51:47) afin d'accélérer le traitement.Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.
Document créé le 11/06/2005, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/servlet/http/Part.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.