Hey,
Im trying to extract numbers from a scanner, but im having problems extracting them all.
Primarily i need it to
- read a text file which contains some text and numbers.
- go through the file and locate all numbers
differentiate between numbers contained in bracket (3), and those on their own 3.
String[] anArray = {
"0", "1", "2",
"3", "4", "5",
"6", "7", "8", "9"
};while(scanfile.hasNext()) { /* add counter up on digits 1-9 on each line * so numbers 1-9 are check on each line */ for(int i =0;i<anArray.length;i++) { if(declarations.hasNext(anArray[i]){ System.out.println("number found"); scanfile.next(); } } scanfile.nextLine(); }
This is what iv done so far, it finds only one number per line, which is a problem, and if a combination such as 77 or 88 appears it doesent recognise them. Any ideas on a more efficient way to achieve the stated task?