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"

            /* 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++)
                    System.out.println("number found");

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?

This bit of code isn't particulary useful in showing us how you are decoding the data. Provide more source code please.

I actually got it working fairly easily using a delimeter but it still lacks the ability to split at a comma, any help correcting the delimeter to include comma's would be useful :)


i tried the above, and it works perfectly except in cases when a comma is after a number, which it believes to not be an int I.e ,50 will be found using nextInt() but 50, will be read as a word for some reason.

Edited 4 Years Ago by trishtren

This question has already been answered. Start a new discussion instead.