So there are test results in a txt file. (In this format: student id (int), First Name (String), Last Name (String), points (double). One student/line).

I need to make an ArrayList<Student> using the txt file (Student has a student id, first name etc.), . I know how to read the text file and make that in to an arraylist and how to tokenize that (using StringTokenizer) but after that I'm lost. I think I could do something with a couple of hundred for loops but that hardly seems like the best way to go about doing this.

So, err help?

Recommended Answers

All 4 Replies

Here's a guidline:

StringTokenizer st = new StringTokenizer(file.readABuchofStuff);
	ArrayList al = new ArrayList();

	while (st.hasMoreTokens())
	{
		StringBuffer sb = new StringBuffer(st.nextToken());
                al.add(sb.toString());
        }

Not very complete, but it should get you going.
Basicly, just use a while look that stop when no tokens are left.

Well it works now, after a bit of struggling with random stuff. Thanks.

So what did you end up with?

Basicly, just use a while look that stop when no tokens are left. :cool:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.