开发者

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:

  1. Read a file into a list of strings
  2. Iterate over two collections of strings and compare them
  3. 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜