Menu

#3 FileParser duplicates lines after error

open
nobody
None
5
2010-03-29
2010-03-29
Anonymous
No

The new FileParser if a line can not be parsed, than processes the line was read before again after calling the exceptionCallback.
To solve this problem I added this line "results = null;" like this:

public void read()
{

MatchedRecord results = null;
boolean exception = false;
do
{
exception = true;

// Attempt to parse the next line
try
{
results = null;
results = ff.getNextRecord(bufIn);
exception = false;
} catch (FlatwormInvalidRecordException ex)
{
doExceptionCallback(ex, "FlatwormInvalidRecordException", ff.getLastLine());
} catch (FlatwormInputLineLengthException ex)
{
doExceptionCallback(ex, "FlatwormInputLineLengthException", ff.getLastLine());
} catch (FlatwormUnsetFieldValueException ex)
{
doExceptionCallback(ex, "FlatwormUnsetFieldValueException", ff.getLastLine());
} catch (FlatwormConversionException ex)
{
doExceptionCallback(ex, "FlatwormConversionException", ff.getLastLine());
} catch (Exception ex)
{
doExceptionCallback(ex, ex.getMessage(), ff.getLastLine());
}

if (null != results)
{
String recordName = results.getRecordName();
doCallback(recordName, results);
}
} while ((null != results) || exception);
}

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.