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

  • Home
  • SEARCH
  • 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 3452022
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:12:33+00:00 2026-05-18T09:12:33+00:00

I have two properties files that contain information. I would like to diff them

  • 0

I have two properties files that contain information. I would like to diff them to see if they are the same. However, in properties files, unless you specify an order to output they write to a file in a different order. I don’t have access to the code just these files. How can I check if their contents are the same?

For example,

File1    File2
a        e
b        c
c        a
d        d
e        b

How can I detect that these two files would be the same? a-e represent strings of information

Thanks!

  • 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-18T09:12:33+00:00Added an answer on May 18, 2026 at 9:12 am

    You have already accepted an answer, but I’ll add this anyway, just to point out that there’s an easier way (assuming you are talking about normal Java properties files).

    You actually don’t have to do any sorting, line-by-line comparison etc. yourself, because equals() in java.util.Properties has been implemented smartly and does what one would expect. In other words, “know and use the libraries“, as Joshua Bloch would say. 🙂

    Here’s an example. Given file p1.properties:

    a = 1
    b = 2
    

    and p2.properties:

    b = 2
    a = 1
    

    …you can just read them in and compare them with equals():

    Properties props1 = new Properties();
    props1.load(new FileReader("p1.properties"));    
    Properties props2 = new Properties();
    props2.load(new FileReader("p2.properties"));
    
    System.out.println(props1.equals(props2)); // true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two properties files that are not the same and I need to
I have a list of objects that have two int properties. The list is
I have some logic that depends upon two properties being set, as it executes
I have two objects List<Report> List<Newsletter> I need certain properties like Id Date Status
I have an object, Test , that has two properties, double x and double
what I'd like to do is have files in a central location so that
I would like to build two C++ projects in the same solution in Visual
I have several classes that need to load some properties files, and I was
What I would like to do is have a standard error message that uses
I have an application that uses several configuration files (let just consider appli.properties here).

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.