dfa using switch
===

help sir, i'm trying to do some simple dfa but it doesn't work right. im trying to test 3 lines of input from a text file which contains, 111, 000,110. i've tried to separate them as 3 tokens but still, when it comes to testing, the program still runs it as a whole. thanks for help in advance


    while(scanLine.hasNextLine())
        {
            String[] tokens = scanLine.next().split("\n");
            
            for(String words : tokens)
            {
              outFile.println(words);
              char[] stringArray = words.toCharArray();
            
            for(char x : stringArray)
            {
                switch(cs)
                {
                    case q0:
                        switch(x)
                        {
                            case '1':
                            cs = q1;
                            break;
                            
                            case '0':
                            cs = q0;
                            break;
                            
                            default:
                            outFile.println("error");
                            break;
                        }
                    break;
                    
                    case q1:
                        switch(x)
                        {
                            case '1':
                            cs = q1;
                            break;
                            
                            case '0':
                            cs = q1;
                            break;
                            
                            default:
                            outFile.print("error");
                            break;
                        }
                    break;
                    
                    default:
                    break;
                }
            }//end for char array
            outFile.println();
            noOfLines++;
            if(cs == q1)
            {
            outFile.println("accepted");
            }
            else
            {
            outFile.println("rejected");
            }//end if else
            }//end for string array
        }