java - How to read first line of ints in a text file, use those numbers, then go to the second line and repeat until the end of the file -


this main method. trying read first line of integers (5 4 3 7 8 4 3 1 3 ) text file. want run numbers through methods calling in main method. want go next line in text file (15 1 60 1 43 24 3), run these numbers through methods calling , on until reach end of text file. best way implement this? how code run through of integers in text file , run them through method.

public static void main(string[] args)  {     binarytree tree = new binarytree();     try      {          int num;         scanner reader = new scanner(new file("numbers.txt"));         while(reader.hasnextint())         {             num = reader.nextint();              if(tree.contains(num))             {                 tree.remove(num);             }             else             {             tree.add(num);             }         }        reader.close();        tree.preorder(root);        system.out.println();        tree.inorder(root);        system.out.println();        tree.postorder(root);        system.out.println("\ntotal: " + tree.size(root));        system.out.println("height: " + tree.height(root));        system.out.println("max: " + tree.getmax(root));        system.out.println("min: " + tree.getmin(root));     }     catch(ioexception e)     {         e.printstacktrace();         system.exit(1);     }   } 

this text file want use called numbers.txt

5 4 3 7 8 4 3 1 3

15 1 60 1 43 24 3

25 28 71 18 48 35 97

6 41 24 40 85 2 92 72 86 59 7 40

76 19 23 40 84 6 67 41 34 66 79 11 38 5 61 60 64 5

81 8 30 80 88 38 90 55 37 45 70 32 41 26

i try more this:

public static void main(string[] args) throws exception {     scanner reader = new scanner(new file("numbers.txt"));      while (reader.hasnextline()) {         string[] temp = reader.nextline().split("\\s+"); // regex , whitespace used delimiter         (int x = 0; x < temp.length; x++) {             // iterate through each element in string array temp         }         // resume while loop.     }  }