Hi need some help to separate my string.

I'm reading my text from file. The format is "name,1,2,3"

What i need to do is to seperate out the entire string to:

String name = "name";
String one = "1";
String two = "2";
String three = "3";

The commas are the seperator to the string.

I've tried to write a for loop to capture the text. but no good results so far.

Can anyone give me a heads up please?

read it using scanner
Scanner in = new Scanner(new File(fileName));
String name = in.next;
String one = in.next;
String two = in.next; .....

Thanks wildplace. I got the codes written and it works! Thank you so much!

import java.util.Scanner;
import java.io.*;
import java.io.File;
import java.io.FileNotFoundException;

    public class scanner
        public static void main(String[] args) throws IOException

			File key = new File("keyRing.txt");

            Scanner scanner =  new Scanner(key).useDelimiter(",");

		//	String name = scanner.next();
		//	System.out.println(name);
			String name,p,g,u,temp;
			String nameToFind="ivan";
            while (scanner.hasNextLine()) {
               //int num = scanner.nextInt();

			temp = scanner.next();
				p = scanner.next();
				g = scanner.next();
				u = scanner.next();
				System.out.println("p: "+p);
				System.out.println("g: "+g);
				System.out.println("u: "+u);


      }//end main
   }//end class
This question has already been answered. Start a new discussion instead.