Examples of TextBody


Examples of com.vtence.molecule.lib.TextBody

        final Sequence sequence = new Sequence();

        server.start((new DynamicRoutes() {{
            get("/albums").to(new Application() {
                public void handle(Request request, Response response) throws Exception {
                    TextBody body = new TextBody();
                    for (int id : albums.keySet()) {
                        Album album = albums.get(id);
                        body.append(String.format("%d: %s\n", id, album.info()));
                    }
                    if (body.text().isEmpty()) {
                        body.append("Your music library is empty");
                    }
                    response.body(body);
                }
            });
View Full Code Here

Examples of org.apache.james.mime4j.dom.TextBody

    /**
     *  code taken from http://www.mozgoweb.com/posts/how-to-parse-mime-message-using-mime4j-library/
     */
    static String getTextPart(Entity part) throws IOException {
        TextBody tb = (TextBody) part.getBody();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        tb.writeTo(baos);
        return baos.toString(MailArchiveServerConstants.DEFAULT_ENCODER.charset().name());
    }
View Full Code Here

Examples of org.apache.james.mime4j.dom.TextBody

    /*
     * taken from http://svn.apache.org/repos/asf/james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java
     */
    private static BodyPart createTextBody(String text, String subtype, boolean isAttachment) {
        TextBody body = new StorageBodyFactory().textBody(text, MailArchiveServerConstants.DEFAULT_ENCODER.charset().name());

        BodyPart bodyPart = new BodyPart();
        if (isAttachment) {
            bodyPart.setContentDisposition("attachment", "file"+Math.random());
        }
View Full Code Here

Examples of org.apache.james.mime4j.dom.TextBody

    /**
     * Creates a text part from the specified string.
     */
    private static BodyPart createTextPart(String text) {
        TextBody body = new StorageBodyFactory().textBody(text, "UTF-8");

        BodyPart bodyPart = new BodyPart();
        bodyPart.setText(body);
        bodyPart.setContentTransferEncoding("quoted-printable");

View Full Code Here

Examples of org.apache.james.mime4j.dom.TextBody

        message.setSubject("Saying Hello");

        // 3) set a text body

        StorageBodyFactory bodyFactory = new StorageBodyFactory();
        TextBody body = bodyFactory.textBody("This is a message just to "
                + "say hello.\r\nSo, \"Hello\".");

        // note that setText also sets the Content-Type header field
        message.setText(body);
View Full Code Here

Examples of org.apache.james.mime4j.dom.TextBody

            if (o instanceof TextBody){
                /*
                 * A text body. Display its contents.
                 */
                TextBody body = (TextBody) o;
                StringBuilder sb = new StringBuilder();
                try {
                    Reader r = body.getReader();
                    int c;
                    while ((c = r.read()) != -1) {
                        sb.append((char) c);
                    }
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
                textView.setText(sb.toString());

            } else if (o instanceof BinaryBody){
                /*
                 * A binary body. Display its MIME type and length in bytes.
                 */
                BinaryBody body = (BinaryBody) o;
                int size = 0;
                try {
                    InputStream is = body.getInputStream();
                    while ((is.read()) != -1) {
                        size++;
                    }
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
                textView.setText("Binary body\n"
                               + "MIME type: "
                                   + body.getParent().getMimeType() + "\n"
                               + "Size of decoded data: " + size + " bytes");

            } else if (o instanceof ContentTypeField) {
                /*
                 * Content-Type field.
View Full Code Here

Examples of org.apache.james.mime4j.dom.TextBody

    /**
     * Creates a text part from the specified string.
     */
    private static BodyPart createTextPart(StorageBodyFactory bodyFactory, String text) {
        // Use UTF-8 to encode the specified text
        TextBody body = bodyFactory.textBody(text, "UTF-8");

        // Create a text/plain body part
        BodyPart bodyPart = new BodyPart();
        bodyPart.setText(body);
        bodyPart.setContentTransferEncoding("quoted-printable");
View Full Code Here

Examples of org.apache.james.mime4j.message.TextBody

            return result;
        }

        private BodyPart humanReadableTextBodyPart() {
            BodyPart result = new BodyPart();
            TextBody textBody = new BodyFactory().textBody(humanReadableText());
            result.setText(textBody);
            return result;
        }
View Full Code Here

Examples of org.apache.james.mime4j.message.TextBody

            return buffer.toString();
        }

        private BodyPart deliveryStatusBodyPart() {
            BodyPart result = new BodyPart();
            TextBody textBody =
                    new BodyFactory().textBody(deliveryStatusText());
            result.setBody(textBody, "message/delivery-status");
            return result;
        }
View Full Code Here

Examples of org.apache.james.mime4j.message.TextBody

        message.setSubject("Saying Hello");

        // 3) set a text body

        BodyFactory bodyFactory = new BodyFactory();
        TextBody body = bodyFactory.textBody("This is a message just to "
                + "say hello.\r\nSo, \"Hello\".");

        // note that setText also sets the Content-Type header field
        message.setText(body);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.