Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getLineNumber() and stack woes

Status
Not open for further replies.

wavo7

Technical User
Jul 18, 2001
11
US
Hello all, I hope you can help me on this one. I've been working on this program, that i want to check html tags to see if they are properly nested and that they are correct. if they are not I want to display an error message telling what line number is broke on and what symbol it was expecting. I'm using a stack, and I haven't totally figured out how i'm going to check them and stuff (so any suggestions there would be greatly appreciated), but my main problem is that my stupid getLineNumber is not working!! I'm reading a file full of arbitrary stuff and looping through it to read all the contents. I've looked online and read all about the LineNumberReader, but for some stupid reason it doesn't want to work for me, it doesn't count at all, it's always at zero. Here's a snippet of my code (the while loop) I was hoping someone could tell me why it isn't counting the line numbers!?? Any help would be so GREATLY appreciated....thanks :)

while((file=thefile.readLine()) != null)
{
count++;
System.out.println(count);
count = objFileReader.getLineNumber();
if (file.indexOf("and")>= 0)
{
System.out.println(count +"found and on line number " + objFileReader.getLineNumber());
}

if (file.indexOf(&quot;<&quot;)>=0)
{
stackem.push(&quot;<&quot;);
System.out.println(&quot;you've been pushed&quot;);
}
else if (file.indexOf(&quot;>&quot;)>=0)
{
stackem.push(&quot;>&quot;);
System.out.println(&quot;found the second guy &quot; + count);
}

System.out.println(file);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top