Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6926383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:54:42+00:00 2026-05-27T10:54:42+00:00

I am trying to decode an outlook .MSG file to a text file, using

  • 0

I am trying to decode an outlook .MSG file to a text file, using Apache POI classes.

Everything works fine, except for the println method of PrintWriter: it doesn´t create a new line.

It just concatenates every sentence directly one after another. The result of the code snippet below is

"De: textPara: " iso 
"De: "
"Para: "

I tried the code on several machines: it works on my local tomcat instalation (Windows machine), but fails on a tomcat or Weblogic instalation on a Solaris platform. I thought it had something to do with the encoding algorithm, so I used PrintStream in stead of Printwriter, indicating the encoding ISO-8859-1, but no luck neither.

Any idea?

    try {
        byte [] msgByte = Base64.decodeBase64(msgBase64);

        InputStream inputMsg = new ByteArrayInputStream(msgByte);
        msg = new MAPIMessage(inputMsg);

        /* 1. Transform MSG to TXT. */
        try {
            txtOut = new PrintWriter(outputMsg);
            try {
                String displayFrom = msg.getDisplayFrom();
                txtOut.println("De: "+displayFrom);
            } catch (ChunkNotFoundException e) {
                _logger.info("Error extrayendo displayFrom: "+e);
            }
            try {
                String displayTo = msg.getDisplayTo();
                txtOut.println("Para: "+displayTo);
            } catch (ChunkNotFoundException e) {
                _logger.info("Error extrayendo displayTo: "+e);
            }

        } finally {
        if(txtOut != null) {
            txtOut.close();}
        else {
            _logger.error("No se ha podido parsear el mensaje.");
        }

        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:54:43+00:00Added an answer on May 27, 2026 at 10:54 am

    Change the following:

    txtOut.print("De: "+displayFrom + "\r\n");
    txtOut.print("Para: "+displayTo + "\r\n");
    

    This is related to how PrintWriter.println() generates the Line break depending of the Operating System. For unix systems is LF (\n), for Windows is CR+LF (\r\n).

    Notice how I added the “\r\n” which means CR+LF and used print() instead of println(). This way the line break generated is not platform dependent.

    You can also add the following method to your class to avoid duplicity and just call this custom println() instead of directly calling txtOut.print().

    private static final String LINE_SEPARATOR = "\r\n";
    
    public void println(String str) {
        txtOut.print(str + LINE_SEPARATOR);
    }
    

    This way you just call println() method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to decode a pcap file and its working fine except couple
I'm parsing a file and trying to decode coordinates to the right unit. What
I am trying to decode a JSON string using json_decode() in PHP. Part of
I'm trying to decode base64-encoded string with openssl. However, it works only 4 times
I am trying to decode this URL string using PHP's urldecode function: urldecode(Ant%C3%B4nio+Carlos+Jobim); This
I am trying to decode a H263 4CIF(704x576) resolution file with ffmpeg, but it
I am trying to decode a string I took from file: file = open
I am trying to decode this little peice of java code (using an oracle10g
I’m playing around with the Stack Overflow API using Python. I’m trying to decode
I'm trying to decode a DAT file produced by Yahoo Messenger, which looks similar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.