473,549 Members | 4,476 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Compare Contents of Two Files

66 New Member
Does anyone know how to compare contents of two ArrayLists? I want to compare them to see if they match up. Do you have an example or could you point me in the right direction. I know I need to loop through it with an if statement a for loop somehow or both, but I am not sure how. thanks for any help you can provide-
Nov 1 '07 #1
26 17322
r035198x
13,262 MVP
Does anyone know how to compare contents of two ArrayLists? I want to compare them to see if they match up. Do you have an example or could you point me in the right direction. I know I need to loop through it with an if statement a for loop somehow or both, but I am not sure how. thanks for any help you can provide-
The objects in the ArrayList are Comparable, right?
When you say you want to see if they "match up" you mean if they contain equal objects at the same locations, right?

Then a simple loop going through the ArrayLists should do it.
Nov 1 '07 #2
CodeTilYaDrop
66 New Member
It is not that simple. I am trying to compare two separate documents, and find where the changes were made. I want to go through some type of loop to find the changes made on one comparred to the other. The contents may be moved all around.
Nov 1 '07 #3
r035198x
13,262 MVP
It is not that simple. I am trying to compare two separate documents, and find where the changes were made. I want to go through some type of loop to find the changes made on one comparred to the other. The contents may be moved all around.
That is not what you said in your original post is it? So these documents are what type? .txt, .odt, e.t.c?
Nov 1 '07 #4
CodeTilYaDrop
66 New Member
They are both text files.
Nov 1 '07 #5
CodeTilYaDrop
66 New Member
They are both text files.
I put them both in an ArrayList though.
Nov 1 '07 #6
r035198x
13,262 MVP
I put them both in an ArrayList though.
What kind of changes are you trying to look for.
It may be better to read the files into two StringBuilders. Open the specs for the StringBuilder class and see what can be done on it.
Nov 1 '07 #7
CodeTilYaDrop
66 New Member
I just want to know the word changes of the two documents. Could I use the indexOf in a loop to notice the changes?
Nov 1 '07 #8
CodeTilYaDrop
66 New Member
What about the contains method. What do you think?
Nov 1 '07 #9
r035198x
13,262 MVP
If you use contains, you would be testing to see if it contains what?
To test for word differences, just look word by word in the files and see if the words are the same.

OK Suppose you have the file initially as

Expand|Select|Wrap|Line Numbers
  1. this
  2. was the 
  3. file before
Then later it becomes
Expand|Select|Wrap|Line Numbers
  1. was this
  2. the
  3. file before
What should the program do?
Nov 1 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
4519
by: Robin Siebler | last post by:
I have two directory trees that I want to compare and I'm trying to figure out what the best way of doing this would be. I am using walk to get a list of all of the files in each directory. I am using this code to compare the file lists: def compare_files(first_list, second_list, first_dir, second_dir): missing =...
2
2909
by: david | last post by:
hi: The file can be PDF or Word format. Any help? thx
19
9491
by: David zhu | last post by:
I've got different result when comparing two strings using "==" and string.Compare(). The two strings seems to have same value "1202002" in the quick watch, and both have the same length 7 which I have tried to print out by debug.writeline(). But the "==" operator results false, and string.Compare() results true. Somebody helps me!
5
1602
by: | last post by:
What is the simplest way to determine if two files are identical (that is, all bytes the same). I want to check to see it the current version of a .jpg file is identical to the original. I wish to ignore any bytes that indicate file attributes (read only, date last accessed etc.) I just need to confirm the contents are unchanged....
2
12322
by: Nitro | last post by:
Does anyone know a simple way to compare two images to see if they are the same? The filenames of the images will be different, but if the image data is the same I would like to test for that. The files will be jpeg images.
5
10041
by: drabee | last post by:
Please help 2 things: 1-I need c# code to compare 2 audio files .or any other .net code 2-code to receive bluetooth file from mobile and save it using .net code
5
5563
by: stamatis32 | last post by:
Hello everybody, i want to make a prog to compare the contents of 2 dirs. You can compare easily 2 files, but how this happend with dirs. I am very confused, i dont know where to start from, can anyone help? I search on many books but i haven't found anything similar
0
1058
by: mlco | last post by:
Pls help. I have 2 wafer maps file for comparison. The checking will only start after the "#" and ended with "##". The file contains; ERROR CODE OK WAFER ID 01 REFERENCE DIE ROWS 74
1
1922
by: raj85 | last post by:
i want to compare 2 same files which is located at different location. i olready created 2 file browser button. now i juz need c# code to do comparing text of the both files. it muct check both contents are same and after tat it should save the result in a "result1.Text=" box and i have a save button on my webpage, when i click tat button i want...
0
7526
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7723
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7480
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7814
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5373
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3504
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.