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 7913133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:46:21+00:00 2026-06-03T13:46:21+00:00

i read several property files to compare them against a template file for missing

  • 0

i read several property files to compare them against a template file for missing keys.

FileInputStream compareFis = new FileInputStream(compareFile);
Properties compareProperties = new Properties();
compareProperties.load(compareFis);

Note: I read the template file the same way.

After reading i compare them and write the missing keys with their values from the template file into a Set.

CompareResult result = new CompareResult(Main.resultDir);
[...]
if (!compareProperties.containsKey(key)) {
    retVal = true;
    result.add(compareFile.getName(), key + "=" + entry.getValue());
}

At last i write the missing keys and their values into a new file.

for (Entry<String, SortedSet<String>> entry : resultSet) {
    PrintWriter out = null;
    try {
        out = new java.io.PrintWriter(resultFile);
        SortedSet<String> values = entry.getValue();
        for (String string : values) {
            out.println(string);
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } finally {
        out.flush();
        out.close();
    }
}

If i open the result file i see that all line breaks “\n” from the values of the template file are replaced against a new line. Example:

test.key=Hello\nWorld!

becomes

test.key=Hello
World!

Although this is basically correct, but in my case I have to keep the “\n”.

Does anyone know how can i avoid that?

  • 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-06-03T13:46:21+00:00Added an answer on June 3, 2026 at 1:46 pm

    Since it seems that your output is a properties file, you should use Properties.store() to generate the output file. This would not only take care of encoding the newline chars, but also the other special characters (non ISO8859-1 characters for example).

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

Sidebar

Related Questions

I'm new to objective-c and I searched and read several posts here on how
I've read several XSRF solutions that rely on adding more tokens to the response,
I have read several post on both matters but I haven't seen anyone comparing
I've read several articles on this issue, and technically speaking, all they end up
I've read several articles that tell you how to add text to the output
I've read several documents on the merits of the different HTTP redirect status codes,
I've read several other questions about material in order to learn RoR. But my
I've read several questions here concerning Tomcat and logging but I still really don't
I've read several sources now but did not find a solution: I'm using Facebook
I have read several questions regarding this but I fear they may be out

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.