Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to compare two documents in java  RSS feed

 
Anshul K Jain
Greenhorn
Posts: 20
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
I have to compare two documents in java.Basically i am generating the document in the HTML format can there is a way that can compare this thing.

Below is the small code which is generated on the jsp page.





Please help me..
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does your requirement define compare?
Output?Source?
 
Anshul K Jain
Greenhorn
Posts: 20
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider the ex.
Suppose i have a document 1 which is generate over the jsp page when i call it. Now i make some changes in the document 1 and save it. Now when i generate the modified document
i need a way that can highlight the portion that are changed.
As we can do with the help of the compare tools.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In that case you can open streams to the two documents, read them one line at a time and compare the lines.
If you are using Swing, you can use the javax.swing.text.Highlighter to highlight the differences
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!