Hello! I'm learning a little bit how to programme in java and I have a work to do. I have to read a file with a lot of lines where each line has 3 numbers: 2 doubles and 1 int (4.5 3.5 7). I'm trying to do like this but it doesn't work... the line in green is the one that it considers as wrong. Does anybody can help me?
Scanner amostra=new Scanner(new File ("file")); String linha =amostra.nextLine(); Scanner leitorLinha=new Scanner (linha); leitorLinha.delimiter(); System.out.println(leitorLinha.nextDouble()); System.out.println(leitorLinha.nextDouble()); System.out.println(leitorLinha.nextInt()); amostra.close(); thanks a lot[code=java]
Hello! I'm learning a little bit how to programme in java and I have a work to do. I have to read a file with a lot of lines where each line has 3 numbers: 2 doubles and 1 int (4.5 3.5 7). I'm trying to do like this but it doesn't work... the line in green is the one that it considers as wrong. Does anybody can help me?
Scanner amostra=new Scanner(new File ("file"));
String linha =amostra.nextLine();
Scanner leitorLinha=new Scanner (linha);
leitorLinha.delimiter();
System.out.println(leitorLinha.nextDouble());
System.out.println(leitorLinha.nextDouble());
System.out.println(leitorLinha.nextInt());
amostra.close();
thanks a lot