so I have had trouble lately with using multiple delimiters in a FileScanner. I would like to do so as the first Strings in my file are separated by commas, but before it goes to the next line there is no comma, only a space. This creates problems with assigning the values to my arrays.
    public class FileScan
    {
         public static void main(String[] args) throws IOException
         {
              String[] firstName = new String[50];
              String[] lastName = new String[50];
              String[] number = new String[50];
              Scanner fileScan = new Scanner(new File("phonebook.txt");
              fileScan.useDelimiter(",");
              for(int i = 0; fileScan.hasNext(); i++)
              {
                   firstName[i] = new firstName[fileScan.next];
                   lastName[i] = new lastName[fileScan.next];
                   number[i] = new number[fileScan.next];
                   System.out.println(firstName[i] +"\t"+ lastName[i] +"\t"+ number[i]);
              }
Because the File looks something like this:
    John, AppleSeed, 800-555-9000
    Jack, Torrance, 450-555-3000
    Elizabeth, MacDonald, 304-555-3042
I want to be able to switch the delimiter during runtime in order to not cause errors. However If I do this:
         fileScan.useDelimiter(",");
         firstName[i] = new firstName[fileScan.next];
         lastName[i] = new lastName[fileScan.next];
         fileScan.useDelimiter(" ");
         number[i] = new number[fileScan.next];
I am still getting errors.The only other possibility I could think of was to just use the default and try to take out the commas after. Is there a better way to do this?
 
     
     
    