Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Text file content should like this:
1.txt : accountsservice :: 0.6.40-2ubuntu11.3 :: None :: amd64 :: None

2.txt : cronie-anacron::1.4.11::17.el7::x86_64::Friday 05 January 2018 11:13:34 
        AM 


What I have tried:

Java
package Programm;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class StringEqual{

public static void main(String[]args){

BufferedReader in = null;
BufferedReader in2 = null;
try {
    in = new BufferedReader(new FileReader("/home/msr/Music/Ubuntu.txt"));
	in2 = new BufferedReader(new FileReader("/home/msr/Music/centos.txt"));
    
    String read = null;
    String read2 = null; 
    while ((read = in.readLine()) != null && (read2 = in2.readLine())!= null) {
        String[] splited = read.split("::");
         String[] spliter = read2.split("::");
   
    
      
   
        for (String part : splited) {
        	if(in!=in2) 
            System.out.println("packages name matches:" + part);
        }
        
        for (String part2 : spliter) {
        	if(in!=in2) 
        	System.out.println("packages not matched:" + part2);
        }
    }
}
 catch (IOException e) {
    System.out.println("There was a problem: " + e);
    e.printStackTrace();
} finally {
    try {
        in.close();
    } catch (Exception e) {
    }
}
}
}
Posted
Updated 2-May-18 22:41pm
v3
Comments
Richard MacCutchan 3-May-18 4:21am    
What is the question?
Member 13809409 3-May-18 4:32am    
i need to compare two text files line by line with other file all lines by two colon separate in java.
if i give package name matches it should be print what are all the package name matched with other file..this is my requirement
inside text file all lines like this:
accountsservice :: 0.6.40-2ubuntu11.3 :: None :: amd64 :: None
Richard MacCutchan 3-May-18 4:36am    
Well that is what you already posted. But you have not explained what the problem is.
Member 13809409 3-May-18 4:58am    
am able to compare with each line with other line only not able to compare each line with all lines with other a file
Richard MacCutchan 3-May-18 6:37am    
Sorry, I appreciate English may not be your language, but that is still not clear. If you are trying to compare three files then you may need to do it with only two at a time. But the issue really is what you want to do when you find a line that does not match with something else. You need to make sure your rules are clear before you start.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900