// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.StringReader;
import java.util.Scanner;

public class ScanFun {
    public static void main(String[] args) {
        String s = "A,1,2,3,4\nBB,5,6,7,8";
        Scanner scn = new Scanner(new StringReader(s));
        scn.useDelimiter("[,\n]");
        while(scn.hasNext()) {
            System.out.println(scn.next());
            System.out.println(scn.nextInt());
            System.out.println(scn.nextInt());
            System.out.println(scn.nextInt());
            System.out.println(scn.nextInt());
        }
    }
}
