Java - StreamTokenizer
From: Merlin (merlin_at_pheonix.fsnet.co.uk)
Date: 06/24/04
- Next message: Chiron Paixos: "Re: Where do I download sax2.jar"
- Previous message: Rick Brandt: "XML Parse Problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 24 Jun 2004 17:31:10 +0100
Hi everyone, I was wondering if anyone would be kind enough to answer a
question on the StreamTokenizer class. As part of my efforts to learn java
i'm writing a class that parses my BlackICE firewall logs. Below is part of
the constructor that i've written so far:
Code:
public LogParser(String inputFile) throws FileNotFoundException,
IOException
{
BufferedReader br = new BufferedReader(new
FileReader(inputFile));
StreamTokenizer st = new StreamTokenizer(br);
st.eolIsSignificant(true);
st.commentChar('#');
st.nextToken();
}
Now I've used to commentChar() method because I want all lines beginning
with a hash to be ignored. The first line in my log starts with a hash so as
stated in the java api I would expect nextToken() to read this and go to the
end of the line. So next when I run nextToken() it should pick up some text
that is on the next line. Yet when I try to output the contents of the token
by say System.out.println(st.sval) I get the value null. Any help with my
stupidity would be appreciated.
- Next message: Chiron Paixos: "Re: Where do I download sax2.jar"
- Previous message: Rick Brandt: "XML Parse Problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|