File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes next question... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "next question..." Watch "next question..." New topic

next question...

Sam Smoot
Ranch Hand

Joined: Apr 18, 2002
Posts: 238
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...

CNSS/NSA Infosec Professional,<br />Software Engineer
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

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 ]

Please ignore post, I have no idea what I am talking about.
Sam Smoot
Ranch Hand

Joined: Apr 18, 2002
Posts: 238
Sounds close to what I need to do...
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
It might work well enough to just put each line in a tree set and then write the tree components to some destination file.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: next question...
It's not a secret anymore!