Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Read the integer list from a file in the given path */
- public static int[] readNumbers(String path) throws FileNotFoundException {
- int[] numbers = new int[100];
- Scanner scanner = new Scanner(new File(path));
- int i = 0; // counter
- while (scanner.hasNextLine()) {
- numbers[i] = Integer.parseInt(scanner.nextLine());
- i++;
- }
- scanner.close();
- return numbers;
- }
Advertisement
Add Comment
Please, Sign In to add comment