• Post Reply Bookmark Topic Watch Topic
  • New Topic

unified format  RSS feed

 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Is there any Java API for creating unified format file ? After doing some search i found this for creating diff file http://www.bmsi.com/java/#diff, but i don't see any option to create unified format . http://en.wikipedia.org/wiki/Diff#Unified_format

If anyone is aware of Java API to create Unified Format, please let me know. Thanks in advance.

~ Raj
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What, exactly, is a "unified format"?
Never mind, somehow I overlooked the Wikipedia link.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think he means "unified diff format", as a continuation of not using an existing solution and bolting on remote file access.
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, thats what i meant "Unified Diff Format"

http://en.wikipedia.org/wiki/Diff#Unified_format
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I search for "java diff" I get a few hits--did those not meet your needs?
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was able to generate the basic diff output . if you are on unix box, the command would look like

$ diff file1.txt file2.txt

To get "Unified Format" , the command on unix is

$ diff -u file1.txt file2.txt

specifically I'm trying to generate the output which should be same as that of

$ diff -aNU20 file1.txt file2.txt

looking at some jars available, i think its possible to create the desired output I'm looking for, with additional coding and some math logic.
Python comes up with package for creating unified diff, http://docs.python.org/library/difflib.html

Looks like there is no solid API available in java for this requirement.

Thank you for the replies, really appreciate looking at this issue for me.

Thanks,
Rajeev
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which libraries did you look at? I see at least three that should generate a unified diff.

Personally, I still think you're approaching this backwards, and that it could be handled either by the OS itself, or by modifying an existing merge solution that only accesses local files.
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
these are the ones i tried.

http://www.bmsi.com/java/#diff

http://code.google.com/p/java-diff-utils/

didn't help me with the desired output im looking for. "java-diff-utils" returns patches which i can use to create "unified format" with context info

thanks,

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!