• Post Reply Bookmark Topic Watch Topic
  • New Topic

Comparing t file data

 
alka gautam
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody tell me whether there is any facility(any
class/function) in Java that I can use to compare two ascii files....??.Please treat this as urgent.
Regards
Alka
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you want the comparison to do? return a boolean (true if same, false if different)? return the index of the first difference it finds? produce some summary of the actual differences (cf 'diff')?
If it is either of the first two, I recommend loading each file into a String and using String.equals() or String.compareTo(). If you need any more than that, you'll probably have to write something, or call out to an external "diff" program.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!