comparing 2 files using java
i have 2 text files, file_1: and the other file2
file_1:
tan开发者_运维知识库go 12
beta 256
alpha 1700
tango 1200
file_2:
tango 12
tango 125 hello world
beta 256
alpha 1700
i need to remove lines in file_2 which contains file_1 entries. ie. read line by line from file_2, compare with file_1 lines, if match , remove , else append to a new file. matches are exact string matches, both are text files. can any one tell me how can i do it using java
Break the problem into steps:
- Read a file into a list of strings
- Iterate over two collections of strings and compare them
- Write to a file
Read both file in to Collection of String.
Then compare two List and process accordingly.
Rest all things are given by duffymo , Here is how to compare two arraylist of String
精彩评论