- Javax.xml.bind classes
- Home
- Binder
- DatatypeConverter
- JAXB
- JAXBContext
- JAXBElement
- JAXBElement.GlobalScope
- JAXBIntrospector
- Marshaller.Listener
- SchemaOutputResolver
- Unmarshaller.Listener
- Javax.xml.bind.util classes
- JAXBResult
- JAXBSource
- ValidationEventCollector
- Javax.xml.parsers classes
- DocumentBuilder
- DocumentBuilderFactory
- SAXParser
- SAXParserFactory
- Javax.xml.soap classes
- AttachmentPart
- MessageFactory
- MimeHeader
- MimeHeaders
- SAAJMetaFactory
- SOAPConnection
- SOAPConnectionFactory
- SOAPFactory
- SOAPMessage
- SOAPPart
- Javax.xml.validation classes
- Schema
- SchemaFactory
- TypeInfoProvider
- Validator
- ValidatorHandler
- Javax.xml.xpath classes
- XPathConstants
- XPathFactory
- Java Useful Resources
- Java - Quick Guide
- Java - Useful Resources
AttachmentPart getNonMatchingMimeHeaders() Method
Description
The Javax.xml.soap.AttachmentPart.getNonMatchingMimeHeaders(String[] names) method retrieves all MimeHeader objects whose name does not match a name in the given array.
Declaration
Following is the declaration for javax.xml.soap.AttachmentPart.getNonMatchingMimeHeaders() method
public abstract Iterator getNonMatchingMimeHeaders(String[] names)
Parameters
names − a String array with the name(s) of the MIME headers not to be returned
Return Value
This method returns all of the MIME headers in this AttachmentPart object except those that match one of the names in the given array. The nonmatching MIME headers are returned as an Iterator object.
Exception
NA
Example
The following example shows the usage of javax.xml.soap.AttachmentPart.getNonMatchingMimeHeaders() method.
package com.tutorialspoint; import java.util.Iterator; import javax.activation.DataHandler; import javax.xml.soap.*; public class AttachmentPartDemo { public static void main(String[] args) { try { // create a new SOAPMessage SOAPMessage message = MessageFactory.newInstance().createMessage(); // create a string as a new attachment String attachment = "This is an attachment"; // get the data handler and assign the attachment DataHandler handler = new DataHandler(attachment, "HandlerHeader"); // create the attachment part AttachmentPart attachPart = message.createAttachmentPart(handler); // add a MIMEHeader attachPart.addMimeHeader("SecondHeader", "header"); // add the attachment part in the message message.addAttachmentPart(attachPart); String[] headers = {"FirstHeader", "SecondHeader"}; // get the non matching headers for headers array Iterator iterator = attachPart.getNonMatchingMimeHeaders(headers); // print them while (iterator.hasNext()) { MimeHeader header = (MimeHeader) iterator.next(); System.out.println("" + header.getName()); } } catch (Exception ex) { ex.printStackTrace(); } } }
If we compile the code and execute it, this will produce the following result −
Content-Type
javax_xml_soap_attachmentpart.htm
Advertisements
To Continue Learning Please Login
Login with Google