Compare 2 text files in java

Compare 2 text files in java

Page 1 of 1

4 Replies - 7169 Views - Last Post: 18 August 2010 - 01:28 AM Rate Topic: -----

#1 girips29  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 13-August 10

Compare 2 text files in java

Posted 13 August 2010 - 12:29 AM

Need to know how to compare 2 text files in java
Is This A Good Question/Topic? 0
  • +

Replies To: Compare 2 text files in java

#2 Dean_Grobler  Icon User is offline

  • D.I.C Regular

Reputation: 39
  • View blog
  • Posts: 390
  • Joined: 15-January 10

Re: Compare 2 text files in java

Posted 13 August 2010 - 01:02 AM

Your question is a bit fague.. In what way do you want to "compare" it?
Was This Post Helpful? 0
  • +
  • -

#3 eZACKe  Icon User is offline

  • Garbage Collector

Reputation: 120
  • View blog
  • Posts: 1,278
  • Joined: 01-June 09

Re: Compare 2 text files in java

Posted 13 August 2010 - 05:53 AM

Have you made an attempt at it yet? You posted this question many hours ago, so what progress have you made? Please post your code thus far and we'll see what we can do to help.

Remember, DIC has a policy where we like to see a good faith effort put forth before we will give out any code. You need to help us so that we can help you! I suggest posting some code quickly, or risk a moderator closing this topic for blatant violation of the rules.
Was This Post Helpful? 0
  • +
  • -

#4 bcranger  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 252
  • View blog
  • Posts: 1,199
  • Joined: 01-February 10

Re: Compare 2 text files in java

Posted 13 August 2010 - 03:18 PM

Well...if you want to compare two text files word for word, I mean exact spacing, etc, you can open up both text files and scan in line by line, then use the equals() method to see if each line matches...
Was This Post Helpful? 0
  • +
  • -

#5 mk.ranjan  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: -5
  • View blog
  • Posts: 26
  • Joined: 28-June 07

Re: Compare 2 text files in java

Posted 18 August 2010 - 01:28 AM

best way to start with reading the files,
Now you can read it in bytes to do the binary comparision,
else read it in character wise so that u can compare with character by character,
else read it line by line for per line comparision etc etc etc.

for reading a file, i would like you to try yourself as this is considered as most basic thing in java, or even you can search on search engines to get the example code.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1