my code is below and i want to read only integers.BUT the text file is starting with text and it stops executing without reading the numbers.
Also i want to add the 3 parameters of each line.
Please help, thanks in advance.
try{ File fl = new File("C:/Users/Mario/Desktop/testing.txt"); //BufferedReader rd = new BufferedReader(new FileReader(fl)); Scanner sc = new Scanner(fl).useDelimiter("\\s+"); LinkedList<Integer> temps = new LinkedList<>(); sc.useDelimiter(System.getProperty("line.separator")); while(sc.hasNext()){ while(sc.next().matches("[0-9]+")){ int num1=sc.nextInt(); int num2=sc.nextInt(); int num3=sc.nextInt(); temps.add(num1+num2+num3); } } for(Integer dat:temps){ System.out.println(dat); } }catch(Exception e){ e.printStackTrace(); } }