This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Comparing t file data  RSS feed

 
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!