Help displaying strings that appear in one text file but not another!
I'm trying to display all of the songs that appear in one text file but not another. However it doesn't display any songs. All help appreciated.
public static void OnlyInIrishCharts()throws IOException
String lineFromFile, line;
String words ;
String peices ;
int count = 1;
result = "The following singles only appear in the Irish Charts: ";
File f1 = new File("IrishTop100Singles.txt");
File f2 = new File("UKTop100Singles.txt");
if (f1.exists() && f2.exists())
Scanner input = new Scanner(f1);
lineFromFile = input.nextLine();
words = lineFromFile.split(";");
Scanner input2 = new Scanner(f2);
found = false;
while(input2.hasNext() && !found)
line = input2.nextLine();
peices = line.split(";");
if(!(words.equals(peices)) && !(words.equals(peices)))
found = true;
if (found = false)
result += (count + ". Title: " + (words) + " Artist: " + (words) + "\n");
JOptionPane.showMessageDialog(null,result,"UK and Irish Charts",1);
JOptionPane.showMessageDialog(null,"File Not Found!", "Error!",0);
Re: Help displaying strings that appear in one text file but not another!
Try debugging the code by adding println statements to show where the execution flow goes and to show the values of variables used in the code. The print out will show you what the computer sees and will help you understand what the problem is.
it doesn't display any songs