本文整理匯總了Java中org.apache.commons.httpclient.methods.multipart.Part.sendParts方法的典型用法代碼示例。如果您正苦於以下問題:Java Part.sendParts方法的具體用法?Java Part.sendParts怎麽用?Java Part.sendParts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.httpclient.methods.multipart.Part
的用法示例。
在下文中一共展示了Part.sendParts方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getBytes
import org.apache.commons.httpclient.methods.multipart.Part; //導入方法依賴的package包/類
/**
* @return a byte array of the message formatted according to the given
* message format.
*/
public byte[] getBytes(MessageContext messageContext, OMOutputFormat format) throws AxisFault {
OMElement omElement = messageContext.getEnvelope().getBody().getFirstElement();
Part[] parts = createMultipatFormDataRequest(omElement);
if (parts.length > 0) {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
try {
// This is accessing a class of Commons-FlieUpload
Part.sendParts(bytesOut, parts, format.getMimeBoundary().getBytes());
} catch (IOException e) {
throw AxisFault.makeFault(e);
}
return bytesOut.toByteArray();
}
return new byte[0]; //To change body of implemented methods use File | Settings | File Templates.
}
示例2: writeRequestBody
import org.apache.commons.httpclient.methods.multipart.Part; //導入方法依賴的package包/類
/**
* Writes the request body to the given {@link HttpConnection connection}.
*
* @param state the {@link HttpState state} information associated with this method
* @param conn the {@link HttpConnection connection} used to execute
* this HTTP method
*
* @return <tt>true</tt>
*
* @throws IOException if an I/O (transport) error occurs. Some transport exceptions
* can be recovered from.
* @throws HttpException if a protocol exception occurs. Usually protocol exceptions
* cannot be recovered from.
*/
protected boolean writeRequestBody(HttpState state, HttpConnection conn)
throws IOException, HttpException {
LOG.trace("enter MultipartPostMethod.writeRequestBody(HttpState state, "
+ "HttpConnection conn)");
OutputStream out = conn.getRequestOutputStream();
Part.sendParts(out, getParts());
return true;
}