Is there any Java API available to compare two files?
I want to compare the following format of files
-> Microsoft Office Word
-> Microsoft Office Excel
-> Microsoft Office PowerPoint
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Is there any Java API available to compare two files?
I want to compare the following format of files
-> Microsoft Office Word
-> Microsoft Office Excel
-> Microsoft Office PowerPoint
Not that I know of in the Java SE. Perhaps there is a third party package. Have you looked at Apache POI?Is there any Java API available to compare two files?
Do you wish to check if the files end in .doc, .xls etc?!I want to compare the following format of files
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputation by clicking the button on their useful posts.
Define 'compare'
I want to get the difference in the content between two files. The difference should be highligted in some color and it should be shown to the user.
Well, thanks God, i found some place, relevant to my poblem. Actually my problem is almost similar. What i want is:
"Suppose there are two huge text files (say 100000 character each), is there any API or efficient algorithm that could compare for changes/differences between two files?"
I will be very thankful to you, please let me know as soon as you can.
Regards...
What does Google return for file compare or file differences?
I've written some programs over the years to to that. Somebody must have one that they are proud of and want to share.
What would you expect as output from such an API if you compared two files which were made from the same content, but one saved with Microsoft Word 95 and the other with Microsoft Word 6.0?I want to get the difference in the content between two files. The difference should be highligted in some color
Do you want to see the differences between the files (like Meld : Home Page) or just get an indication of how different they are?Suppose there are two huge text files (say 100000 character each),
Doesn't technically answer my question. For word documents, there could be differences on the byte level, but not directly visible at the content level (see sean's post). Or there could be formatting differences, but not text differences...so, do you want to compare the bytes, formatting, content (I presume the latter)?I want to get the difference in the content between two files. The difference should be highligted in some color
Well, i am asking for an API that could work like (Getting two files, compaing for the differences among text and output is like the differences of text between two files, as if you have used repository software, when you do Show differences, it shows you difference between two versions and tell highlight where difference lies). That's what i am asking. Please let me know.
As far as I know there is no standard API for this as there is no standard way to define "different". Consider 2 files.
File 1
aaa
bbb
ccc
ddd
File 2
zzz
aaa
bbb
ccc
ddd
How do you determine the differences? I can quickly say that the only differnce is the second file has zzz at the beginning. But if you were to compare the files line by line then it would highlight that every line is different (aaa != zzz, bbb != aaa, etc). Plus what do you do when with the last line in the second file as there is no line in the first file to compare it to?
Improving the world one idiot at a time!
Junky: Did you use SVN or VSS?
Last edited by Mr.777; August 11th, 2011 at 03:02 AM.
If you want to compare the text from two files saved in a (potentially different version of a) proprietary format, then you need something that understands the proprietary format - you can exclude all text-based comparison software. There's a thread at stackoverflow which mentions one or two of what I expect would be a very few options:
http://www.google.com/search?q=java%...20word%20files
Is there any Java API available to compare two microsoft word documents? - Stack Overflow
It's a much more complicated task than text comparison, you might have to do a lot of work yourself to get something that works the way you want it for all your use cases.
Mr.777 (August 11th, 2011)
Thanks Sean4u for sharing such informative links. Did great help....
I am not sure where to ask about ocx4j.jar....
Can i ask here or some other place???
This is much related to this question that's why i posted here.
This thread has been cross posted here:http://www.java-forums.org/forum-lobby/62441-help-please.html
Although cross posting is allowed, for everyone's benefit, please read: