Yin
Junior Member
umm...let me meditate and get my answer...umm
Posts: 21
|
Post by Yin on Feb 4, 2002 18:24:02 GMT -5
I read some inputs from the bufferedReader for the method getReadyForNext(), yet when i call this method somewhere else, it tells me that i need to throw IOExcepton, but when i do that, it tells me that i cna't override the method in iterator.... shouldi use try and catch ? or is there a better way to solve this problem?ie) reading the inputs from somewhere else? thx~~~
|
|
|
Post by Sky on Feb 4, 2002 21:19:01 GMT -5
if your getReadyForNext() method is declared at private (as in the handout)...then u can only call it within TagIterator...not outside of the class but i doubt that u can change it to public and use it else where...cuz the implement of Iterator only have those specific public methods...not sure about that tho...but i think the autotesting program won't call the getReadyForNext() method directly
|
|
Yin
Junior Member
umm...let me meditate and get my answer...umm
Posts: 21
|
Post by Yin on Feb 4, 2002 21:29:43 GMT -5
getReadyForNext() method is declared as private, but i didn't call it outside of the class. i called it from another method in TagIterator (one of those from Iterator ie) next,hasNext) therefore i can't use throw IOException on that method (but getReadyForNext needs to throw IOException) should i make another method just to read the lines?
|
|
|
Post by Sky on Feb 4, 2002 21:38:25 GMT -5
there shouldn't be any IOException in the assignment do u copy the piece of code from the course website about try and catch?...it's in the A2 hints/tips page i guess
|
|
Yin
Junior Member
umm...let me meditate and get my answer...umm
Posts: 21
|
Post by Yin on Feb 4, 2002 22:22:21 GMT -5
OH!!!!!!!!thank you thank you thank you!!!!!!! i really need to check my eyes :*( i saw every announcement EXCEPT for the one that got me stuck for hours......geez!!! thx again!!
|
|
|
Post by Yingster on Feb 5, 2002 20:37:34 GMT -5
heh heh, i had the same problem
|
|
|
Post by CooLiBoP on Feb 6, 2002 21:32:19 GMT -5
I tried: private String readLine() { String s = null; try { s = br.readLine(); } catch(IOException e) {} return s; } But I keep getting a nullpointer Exception when I try to do something like line = readLine(); ACK!
|
|
|
Post by Yingster on Feb 6, 2002 21:38:46 GMT -5
the code should work did u initliaze line = ""??
it's prob some other problem
|
|
|
Post by CooLiBoP on Feb 6, 2002 22:20:24 GMT -5
the code should work did u initliaze line = ""?? it's prob some other problem Yes! I can't figure the god damn thing out...my whole proggie doesn't work because of this!
|
|
|
Post by Yingster on Feb 6, 2002 22:37:59 GMT -5
i spent 2 days starring at my program and one night, i'd prob have to do the same tonight
mine's not working either
|
|
|
Post by Sylph on Feb 6, 2002 23:27:04 GMT -5
is the file name ur reading from correct?
|
|
|
Post by Yingster on Feb 6, 2002 23:38:53 GMT -5
how do u actually iterate through the html file? my program can only read one line any hints would be greatly appreciated i meant one tag
|
|
|
Post by Sylph on Feb 6, 2002 23:45:02 GMT -5
since ur buffered reader isn't a non-local variable in ur class, it'll still be there if u use it next time. so it'll continue where it left off. but i think u mean 1 line at a time? u can somehow keep track of where u are in the line until it finishes the line...
|
|
|
Post by Yingster on Feb 6, 2002 23:57:38 GMT -5
say i have a file <html> blah more blah ... </html>
when i call next, i get <html> when i call next again, i still get <html>
|
|
|
Post by Sylph on Feb 7, 2002 0:16:51 GMT -5
then there's something wrong w/ ur next() method, not ur readLine() method. maybe u can make a main in ur TagIterator class for now, and test if readLine() works..
|
|