How to ignore the translation of lines and spaces when typing? The input stream contains a set of integers separated from each other by an arbitrary number of spaces and line breaks. It is necessary to put these numbers in the list. When entering numbers are read only before the newline.
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String numbers = reader.readLine(); Scanner scanner = new Scanner(numbers); ArrayList<Double> num = new ArrayList<>(); while (scanner.hasNext()){ if(scanner.hasNext()) num.add(scanner.nextDouble()); else scanner.nextLine(); }
игнорировать перевод строк и пробелов при вводе? - post_zeewreadLinemethod works exactly like this (data stops reading when the line is translated). - java1cprog