java - File not found when using multiple scanners -


i'm writing simple program in eclipse input , compare 2 text files. however, can't seem import 2 text files @ same time. if delete 1 of new scanner objects, clears other file; otherwise, gives me error file not found on both. both files in same place in source folder. code follows:

textfile1 = new file("text1.txt"); scanner text1 = new scanner(textfile1); textfile2 = new file("text2.txt"); scanner text2 = new scanner(textfile2); 

thanks in advance!

try code try-catch block , let me know if worked or not.

// compiler complains if there scanner opened without try-catch block around  try {              final file file1 = new file("text1.txt"); //it thing make file final, gives easy reference reader               final file file2 = new file("text2.txt");              scanner t1 = new scanner(file1);              scanner t2 = new scanner(file2);              //after done close scanner              t1.close();              t2.close();          } catch (filenotfoundexception ex) {          }


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -