我使用的两个文件是 1.Details.txtCode|Account No.|City100051001|999001|Delhi200051003|999002|Kanpur180051012|999003|Jammu2.Sal.txtCode|Amount 100051001|100200051001|200180051012|123输出应该是100051001 999001 Amount 100 INR Delhi180051012 999003 Amount 123 INR Jammu我试过的代码如下:-//Code to get the outputimport java.io.BufferedReader;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.IOException;import java.util.ArrayList;import java.util.Collections;public class compareArrayList { public static void main(String[] args) throws FileNotFoundException { String credit_file_name ="C:/transfer/Sal.txt"; String file_branches ="C:/transfer/Details.txt"; BufferedReader reader0; BufferedReader reader1; ArrayList<String> branch_list = new ArrayList<String>(); ArrayList<String> credit_file = new ArrayList<String>(); try { reader0 = new BufferedReader(new FileReader(file_branches)); reader1 = new BufferedReader(new FileReader(credit_file_name)); String data =""; String acct_num = ""; String city =""; String amount1 =""; String line0 = reader0.readLine(); String line1 = reader1.readLine(); while (line0 != null) { branch_list.add(line0); line0 = reader0.readLine(); } Collections.sort(branch_list); reader0.close(); while (line1 != null) { } } }我得到的输出如下:-100051001 999001 Amount 100 INR Delhi180051012 999003 Amount 123 INR Jammu180051012 999003 Amount 123 INR Jammu这有重复的记录。
添加回答
举报
0/150
提交
取消