Need Serious Help with method using StringTokenizer

Hello i need some serious help with a method using String Tokenizer.

I have a set of bookings saved in a string variable in the following order.

"day^time^customer^type". This is wat i have stored in my String variable:

"15^6^Jon Wright^regular

2^1^Mike Scott^supreme

7^2^Don Valley^regular"

ok i hope everyone got wat i wrote..i have another method where i check the parameters and see if those days have been booked or not. i need to use String Tokenizer to first remove '\n" and then again to remove "^". But i dont know how run a loop and check for all the 3 bookings. Here is my codings...i hope someone can help me....

publicboolean checktimings (int day,int time)throws IOException{

String book = getBookings();

String daytimecheck ="";

String piececheck ="";

String check2 ="";

StringTokenizer next;

StringTokenizer token =new StringTokenizer (book,"\n");

while (token.hasMoreTokens()){

daytimecheck = token.nextToken();

next =new StringTokenizer (daytimecheck,"^");

piececheck = next.nextToken();

check2 = next.nextToken();

}

int dayc = Integer.parseInt(piececheck);

int dayd = Integer.parseInt(check2);

if day == dayc && time == dayd{returntrue;}

else{returnfalse;}

}

i know this code doesn't work...can anyone help me..?

[2295 byte] By [khanplus2005a] at [2007-10-2 4:38:32]
# 1
I really need to know how to do this for tomorrow...
khanplus2005a at 2007-7-16 0:11:33 > top of Java-index,Java Essentials,Java Programming...
# 2

Well I hate the StringTokenizer I don't know why... but..

your while loop will loop through all three lines reassigning those two ints so you will only get the day/time of the last line.

I would return true if the day is available.

The way you are doing your return seems wrong you should only return false when you have an already booked date.In other words keep it all in the loop except put a return true after the loop because that means the date is not booked.

Briganda at 2007-7-16 0:11:33 > top of Java-index,Java Essentials,Java Programming...
# 3
the dayc and dayd only gives me the last 2 values...how can i run the loop to check for all the days and times....its so confusing...darn....i dont want to just get the day and time of the last booking..i wanna find a way to test for all the days and times...
khanplus2005a at 2007-7-16 0:11:33 > top of Java-index,Java Essentials,Java Programming...
# 4

I said in the post above perhaps to cryptically put all those checks inside the while loop the only thing you don't want in the while loop is a "return true" statement... but you do want a "return false" statement in the while loop.

its not a heafty change move your loop closing bracket and adjust your test statement a bit.

Briganda at 2007-7-16 0:11:33 > top of Java-index,Java Essentials,Java Programming...