I have some java code that takes a html table and turns it into an Iterator that I use a while loop to parse and add to a database. My problem is the header of the table is causing me problems while I am going through my while look(since its not passing my data quality checks). Is there a way to skip the first row?
Iterator HoldingsTableRows = HoldingsTableRows.iterator();
while (HoldingsTableRows.hasNext()) {
}
I could get the contents of a variable and if it matches I can break out of the loop but I'm trying to avoid hard coding anything specific to the header names because if the names of the headers change it would break my app.
please help!
Thanks!
All you need to do is call .next()
once before you begin your while loop.
Iterator HoldingsTableRows = HoldingsTableRows.iterator();
//This if statement prevents an exception from being thrown
//because of an invalid call to .next()
if (HoldingsTableRows.hasNext())
HoldingsTableRows.next();
while (HoldingsTableRows.hasNext())
{
//...somecodehere...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With