sandeepmur
Programmer
Hi,
I have a text file with 2 lines:
client=24
clientname=dragon
I am trying to use a stream tokenizer to open and read the file but having some problems. my code is as follows:
StreamTokenizer tokenizer = new StreamTokenizer(new FileReader("res.txt"
);
int nextTok = tokenizer.nextToken();
while (StreamTokenizer.TT_EOF != nextTok) {
if (StreamTokenizer.TT_NUMBER == tokenizer.ttype) {
out.println("It's a number!"
;
out.print (tokenizer.nval + " "
;
}
else if (StreamTokenizer.TT_WORD == tokenizer.ttype) {
out.print (tokenizer.sval + " "
;
}
}
Its taking an awfully long time to read the file. Is there a better way to read the text file?
I need the values 24 and dragon in 2 different strings.
appreciate any help..
thnx,
sg
I have a text file with 2 lines:
client=24
clientname=dragon
I am trying to use a stream tokenizer to open and read the file but having some problems. my code is as follows:
StreamTokenizer tokenizer = new StreamTokenizer(new FileReader("res.txt"
int nextTok = tokenizer.nextToken();
while (StreamTokenizer.TT_EOF != nextTok) {
if (StreamTokenizer.TT_NUMBER == tokenizer.ttype) {
out.println("It's a number!"
out.print (tokenizer.nval + " "
}
else if (StreamTokenizer.TT_WORD == tokenizer.ttype) {
out.print (tokenizer.sval + " "
}
}
Its taking an awfully long time to read the file. Is there a better way to read the text file?
I need the values 24 and dragon in 2 different strings.
appreciate any help..
thnx,
sg