Search code examples
javamimemultipartmime-message

How read the body content from multi part data using java?


I am new to multi part data. I need to parse and read body content of multi part data. Following below is my multi part data. To be specific my data is embedded inside a soap message, not sure if it's relevant.

Using Java I intend to parse and get only the content in bold from the below multi part data, as that's my actual data.

Please help. Thanks in Advance

--MIMEBoundary_8589d345264cb1f477a630c11ab99948c31ab3bfccba010e Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml" Content-Transfer-Encoding: binary Content-ID: <[email protected]>

--MIMEBoundary_8589d345264cb1f477a630c11ab99948c31ab3bfccba010e Content-Type: application/octet-stream Content-Transfer-Encoding: binary Content-ID: <[email protected]>

X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H* --MIMEBoundary_8589d345264cb1f477a630c11ab99948c31ab3bfccba010e--


Solution

  • You can do it by creating an instance of multipartReport like

    MultipartReport multipartReport = new MultipartReport(mimeMessageInstance.dataHandler.dataSource);
    

    and then get the body part using multipartReport