Package org.apache.james.mime4j.message

Examples of org.apache.james.mime4j.message.Message.writeTo()


    protected void runTest() throws Throwable {
        MimeEntityConfig config = new MimeEntityConfig();
        config.setMaxLineLen(-1);
        Message inputMessage = new Message(new FileInputStream(file), config);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        inputMessage.writeTo(out, MessageUtils.LENIENT);
       
        String msgoutFile = file.getAbsolutePath().substring(0, file.getAbsolutePath().lastIndexOf('.')) + ".out";
        String msgoutFileMime4j = file.getAbsolutePath().substring(0, file.getAbsolutePath().lastIndexOf('.')) + ".mime4j.out";
       
        try {
View Full Code Here


            CodecUtil.copy(new FileInputStream(msgoutFile), expectedstream);
            assertEquals("Wrong Expected result", new String(expectedstream.toByteArray()), new String(out.toByteArray()));
           
            Message roundtripMessage = new Message(new FileInputStream(msgoutFile), config);
            ByteArrayOutputStream outRoundtrip = new ByteArrayOutputStream();
            roundtripMessage.writeTo(outRoundtrip, MessageUtils.LENIENT);
            assertEquals("Failed LENIENT roundtrip", new String(out.toByteArray()), new String(outRoundtrip.toByteArray()));

            roundtripMessage = new Message(new FileInputStream(msgoutFile), config);
            outRoundtrip = new ByteArrayOutputStream();
            roundtripMessage.writeTo(outRoundtrip, MessageUtils.STRICT_ERROR);
View Full Code Here

            roundtripMessage.writeTo(outRoundtrip, MessageUtils.LENIENT);
            assertEquals("Failed LENIENT roundtrip", new String(out.toByteArray()), new String(outRoundtrip.toByteArray()));

            roundtripMessage = new Message(new FileInputStream(msgoutFile), config);
            outRoundtrip = new ByteArrayOutputStream();
            roundtripMessage.writeTo(outRoundtrip, MessageUtils.STRICT_ERROR);
            assertEquals("Failed STRICT roundtrip", new String(out.toByteArray()), new String(outRoundtrip.toByteArray()));

        } catch (FileNotFoundException e) {
            FileOutputStream fos = new FileOutputStream(msgoutFileMime4j);
            fos.write(out.toByteArray());
View Full Code Here

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

        // 4) print message to standard output

        message.writeTo(System.out);

        // 5) message is no longer needed and should be disposed of

        message.dispose();
    }
View Full Code Here

        // setMultipart also sets the Content-Type header field
        message.setMultipart(multipart);

        // 4) print message to standard output

        message.writeTo(System.out);

        // 5) message is no longer needed and should be disposed of

        message.dispose();
    }
View Full Code Here

        // Create a new message by transforming the template.
        Message transformed = transform(template);

        // Print transformed message.
        System.out.println("\n\nTransformed message:\n--------------------\n");
        transformed.writeTo(System.out);

        // Messages should be disposed of when they are no longer needed.
        // Disposing of a message also disposes of all child elements (e.g. body
        // parts) of the message.
        transformed.dispose();
View Full Code Here

    }
  
    protected void runTest() throws Throwable {
        Message inputMessage = new Message(new FileInputStream(file));
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        inputMessage.writeTo(out, MessageUtils.LENIENT);
       
        String msgoutFile = file.getAbsolutePath().substring(0, file.getAbsolutePath().lastIndexOf('.')) + ".out";
        String msgoutFileMime4j = file.getAbsolutePath().substring(0, file.getAbsolutePath().lastIndexOf('.')) + ".mime4j.out";
       
        try {
View Full Code Here

            CodecUtil.copy(new FileInputStream(msgoutFile), expectedstream);
            assertEquals("Wrong Expected result", new String(expectedstream.toByteArray()), new String(out.toByteArray()));
           
            Message roundtripMessage = new Message(new FileInputStream(msgoutFile));
            ByteArrayOutputStream outRoundtrip = new ByteArrayOutputStream();
            roundtripMessage.writeTo(outRoundtrip, MessageUtils.LENIENT);
            assertEquals("Failed LENIENT roundtrip", new String(out.toByteArray()), new String(outRoundtrip.toByteArray()));

            roundtripMessage = new Message(new FileInputStream(msgoutFile));
            outRoundtrip = new ByteArrayOutputStream();
            roundtripMessage.writeTo(outRoundtrip, MessageUtils.STRICT_ERROR);
View Full Code Here

            roundtripMessage.writeTo(outRoundtrip, MessageUtils.LENIENT);
            assertEquals("Failed LENIENT roundtrip", new String(out.toByteArray()), new String(outRoundtrip.toByteArray()));

            roundtripMessage = new Message(new FileInputStream(msgoutFile));
            outRoundtrip = new ByteArrayOutputStream();
            roundtripMessage.writeTo(outRoundtrip, MessageUtils.STRICT_ERROR);
            assertEquals("Failed STRICT roundtrip", new String(out.toByteArray()), new String(outRoundtrip.toByteArray()));

        } catch (FileNotFoundException e) {
            FileOutputStream fos = new FileOutputStream(msgoutFileMime4j);
            fos.write(out.toByteArray());
View Full Code Here

        byte[] inputByte = getRawMessageAsByteArray();

        Message m = new Message(new ByteArrayInputStream(inputByte));
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        m.writeTo(out);

        InputStream output = new ByteArrayInputStream(out.toByteArray());

        int b = -1;
        int i = 0;
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.