Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

next question...

 
Sam Smoot
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need opinion / ideas... I need to take 2 files and merge them, but not in the normal way. I need to take a "production" properties file (yes, this is for a Struts Application) and merge it with the latest "Test/verification" version for movement to a production environment. Each file is about 2,000 lines long.
My question is, should I:
A> put each in an array and check them item by item putting the updated entries (as well as the unchanged entries) to a new file to be moved to the production file...
B> put one of them in an array and read the other one, doing the same as above...
C> Some other gee whiz magic / api class that I'm not aware of to put them together without a lot of overhead....
I can't just merge the files because of duplicates and such and I can't delete production and replace with test because all entries may not be present in either...
Thanks..
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved a problem very much like this one, but in a different way. Trying to do a smart merge of these files is going to really hard, and error prone.
My solution was to have a single data file which contained configuration information for all environments. The information in this file was formatted so that there was a consistent way of defining things.

Than you have a seperate script/program which is able to generate the configuration file which is correct for any given environment.
One advantage of doing things this way is that you are able to place the data file into source control.
[ March 26, 2003: Message edited by: William Barnes ]
 
Sam Smoot
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds close to what I need to do...
Thanks!
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might work well enough to just put each line in a tree set and then write the tree components to some destination file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic