try { baos = new ByteArrayOutputStream(); dh.writeTo(baos); } catch (Exception e) {
public static String getMessage(MimeMessage mimeMessage) throws MessagingException, IOException { DataHandler dataHandler = mimeMessage.getDataHandler(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); dataHandler.writeTo(baos); baos.flush(); return baos.toString(); }
protected String getMessage(MimeMessage mimeMessage) throws MessagingException, IOException { DataHandler dataHandler = mimeMessage.getDataHandler(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); dataHandler.writeTo(baos); baos.flush(); return baos.toString(); }
/** * Output the body part as an RFC 822 format stream. * * @exception IOException if an error occurs writing to the * stream or if an error is generated * by the javax.activation layer. * @exception MessagingException for other failures * @see javax.activation.DataHandler#writeTo */ public void writeTo(OutputStream os) throws IOException, MessagingException { // see if we already have a LOS LineOutputStream los = null; if (os instanceof LineOutputStream) { los = (LineOutputStream) os; } else { los = new LineOutputStream(os); } // First, write out the header @SuppressWarnings("unchecked") Enumeration<String> hdrLines = getAllHeaderLines(); while (hdrLines.hasMoreElements()) los.writeln(hdrLines.nextElement()); // The CRLF separator between header and content los.writeln(); // Finally, the content, already encoded. getDataHandler().writeTo(os); os.flush(); }
/** * Output the body part as an RFC 822 format stream. * * @exception IOException if an error occurs writing to the * stream or if an error is generated * by the javax.activation layer. * @exception MessagingException for other failures * @see javax.activation.DataHandler#writeTo */ @Override public void writeTo(OutputStream os) throws IOException, MessagingException { // see if we already have a LOS LineOutputStream los = null; if (os instanceof LineOutputStream) { los = (LineOutputStream) os; } else { los = new LineOutputStream(os); } // First, write out the header Enumeration<String> hdrLines = getAllHeaderLines(); while (hdrLines.hasMoreElements()) los.writeln(hdrLines.nextElement()); // The CRLF separator between header and content los.writeln(); // Finally, the content, already encoded. getDataHandler().writeTo(os); os.flush(); }
os = MimeUtility.encode(os, restrictEncoding(part, part.getEncoding())); part.getDataHandler().writeTo(os);
os = MimeUtility.encode(os, restrictEncoding(part, part.getEncoding())); part.getDataHandler().writeTo(os);
public static byte[] toBytes(DataHandler handler) throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); handler.writeTo(output); return output.toByteArray(); }
@Override protected byte[] getBytes(Object object) { DataHandler handler = (DataHandler) object; ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { handler.writeTo(baos); } catch (IOException e) { throw new RuntimeException(e); } return baos.toByteArray(); } }
@Override protected byte[] getBytes(Object object) { DataHandler handler = (DataHandler) object; ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { handler.writeTo(baos); } catch (IOException e) { throw new RuntimeException(e); } return baos.toByteArray(); } }
public void writeTo(MessageContext messageContext, OMOutputFormat format, OutputStream outputStream, boolean preserve) throws AxisFault { DataHandler dh = getDataHandler(messageContext); if (dh != null) { try { dh.writeTo(outputStream); } catch (IOException e) { throw new AxisFault("Error serializing binary content of element : " + BaseConstants.DEFAULT_BINARY_WRAPPER, e); } } }
public void writePart(DataHandler dataHandler, String contentTransferEncoding, String contentID, List/*<Header>*/ extraHeaders) throws IOException { OutputStream partOutputStream = writePart(dataHandler.getContentType(), contentTransferEncoding, contentID, extraHeaders); dataHandler.writeTo(partOutputStream); partOutputStream.close(); }
public EncodedData getBytesFromDataHandler(DataHandler handler) { ByteArrayOutputStream output = new ByteArrayOutputStream(); try { handler.writeTo(output); } catch (IOException ex) { throw ConversionException.couldNotBeConverted(handler, byte[].class, ex); } return new EncodedData(output.toByteArray(), handler.getContentType()); }
@Override protected void checkMessageData(XMLMessage expected, XMLMessage actual) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); Attachments attachments = actual.getAttachments(); DataHandler dataHandler = attachments.getDataHandler(contentID); assertNotNull(dataHandler); dataHandler.writeTo(baos); assertTrue(Arrays.equals(attachmentContent, baos.toByteArray())); } }
@Override public void writeTo(OutputStream os) { JwsOutputStream jwsOutStream = new JwsOutputStream(os, sig, false); try { handler.writeTo(jwsOutStream); jwsOutStream.flush(); } catch (Exception ex) { throw new JwsException(JwsException.Error.INVALID_SIGNATURE); } } }
public void write(OutputStream os) throws IOException { //build attachment frame writeln("--"+boundary, os); writeMimeHeaders(dh.getContentType(), contentId, os); dh.writeTo(os); writeln(os); } }
public void write(OutputStream os) throws IOException { //build attachment frame writeln("--"+boundary, os); writeMimeHeaders(dh.getContentType(), contentId, os); dh.writeTo(os); writeln(os); } }
public void writeDataHandler(DataHandler dataHandler, String contentID, boolean optimize) throws IOException, XMLStreamException { finishStartElementIfNecessary(); Base64EncodingWriterOutputStream out = new Base64EncodingWriterOutputStream(new ContentHandlerWriter(contentHandler), 4096, true); dataHandler.writeTo(out); out.complete(); }