|
SAP NetWeaver 7.31 Enterprise Portal (SP 16) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sapportals.portal.prt.util.http.MultiPartParser
public class MultiPartParser
This class offers parsing functionality for multipart/form-data content provided by an
inputstream and a given boundary. See
RFC 1341 for more details.
Suppose you are given an InputStream in and a boundary String boundary.
The following code reads all parts, their headers and their bodies, in a servlet style...
MultiPartParser parser = new MultiPartParser(in,boundary);
if (parser.onValidPart())
{
while (parser.onValidPart())
{
out.println("-------- PART ----------<br>");
Enumeration headers = parser.getHeaderFields();
if (headers!=null)
{
out.println("<table>");
while (headers.hasMoreElements())
{
String name = (String) headers.nextElement();
String value = parser.getHeaderValue(name);
out.println("<tr><td>"+name+"</td><td>"+value+"</td></tr>");
}
out.println("</table>");
}
// now read the parts data.
InputStream partIn = parser.getPartInputStream();
if (partIn!=null)
{
int c=0,count=0;
while ((c=partIn.read())!=-1) count++;
out.println("read "+count+" bytes from the part's data.<br>");
}
else
{
out.println("Failed to retrieve a part inputstream<br>");
}
parser.proceedToNextPart();
}
}
Copyright (c) SAP Portals Europe GmbH 2001
| Constructor Summary | |
|---|---|
MultiPartParser(InputStream in,
String boundary)
Constructs a parser from an InputStream and a boundary. |
|
| Method Summary | |
|---|---|
Hashtable |
getFileParts()
|
Enumeration |
getHeaderFields()
Gets an enumeration of all header fields of the current header. |
String |
getHeaderValue(String header)
Gets the value of a specified part header field. |
Hashtable |
getParameterParts()
|
InputStream |
getPartInputStream()
|
boolean |
onValidPart()
Returns whether we are currently in front of a part. |
void |
proceedToNextPart()
Proceeds to the header of the next part. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MultiPartParser(InputStream in,
String boundary)
throws IOException
in - The inputstream containing the multipart databoundary - The boundary separating the individual parts
IOException| Method Detail |
|---|
public boolean onValidPart()
true if the parser is ready to read a parts data.
In that case, there is valid header information and the parts body available.
false otherwise.
public void proceedToNextPart()
throws IOException
IOExceptionpublic Enumeration getHeaderFields()
public String getHeaderValue(String header)
header - The name of a part's header field
public InputStream getPartInputStream()
public Hashtable getParameterParts()
public Hashtable getFileParts()
| Access Rights |
|---|
| SC | DC | Public Part | ACH |
|---|---|---|---|
[sap.com] EP-BASIS-API
|
[sap.com]
|
default
|
EP-PIN-PRT
|
[sap.com] EP-BASIS-API
|
[sap.com] tc/epbc/prt/api
|
api
|
EP-PIN
|
[sap.com] EP-BASIS-API
|
[sap.com] tc/epbc/prt/lib/api
|
api
|
EP-PIN
|
[sap.com] EP-RUNTIME
|
[sap.com] tc/ep/semantics/api
|
api
|
EP-PIN
|
[sap.com] KMC-WPC
|
[sap.com] tc/kmc/wpc/wpcfacade
|
api
|
EP-PIN-WPC-WCM
|
|
SAP NetWeaver 7.31 Enterprise Portal (SP 16) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||