Hello i would like to know the best and easiest way to scan an int number from a txt file one digit after another the numbers i can find is 0 to 9 non else for example:
24351235312531135
i want to get each time im scanning these inputs
2
4
3
5
1
2
EDIT:
My input in txt file is something like this
13241235135135135
15635613513513531
13513513513513513
13251351351351353
13245135135135315
13513513513513531
6 lines with a known number of digits .... i have found this code but is not working
import java.util.Scanner;
public class ScannerReadFile {
public static void main(String[] args) {
// Location of file to read
File file = new File("data.txt");
try {
Scanner scanner = new Scanner(file);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
System.out.println(line);
}
scanner.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
im unable to find the exact query im facing