/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package com.oracle.java.corelibs;

import java.util.Scanner;

/**
 *
 * @author ababroy
 */
public class JI9047876 {
    public static void main(String[] args) { 

    // generate test string: (1022x "a") + (3x ";") 
    String testLine = ""; 
    for (int i = 0; i < 1022; i++) { 
        testLine = testLine + "a"; 
    } 
    testLine = testLine + ";;;"; // Works fine if the range of 'i' is 1-1022
//    testLine = testLine + ";;;;"; // Works fine for any value of i
    

    // set up the Scanner variable 
    String delimeter = ";"; 
    Scanner lineScanner = new Scanner(testLine); 
    lineScanner.useDelimiter(delimeter); 
    int p = 0; 

    // tokenization 
    while (lineScanner.hasNext()){ 
            p++; 
            String currentToken = lineScanner.next(); 
            System.out.println("token" + p + ": '" + currentToken + "'"); 
    } 
    lineScanner.close(); 
} 
}
