I have gone over and over this code and can’t see where this is happening it doesn’t happen every time it only happens if I run through post twice but I have tried getting rid of each of these in turn by commenting them out and that still gives the error but if I get rid of both my code works fine but they are necessary and they did work before. Any help is appreciated.
if(lines[i].length() > 10)
{
if(lines[i].charAt(4) == '-' && lines[i+1].charAt(4) == '-')
{
lines[i] = "\nComment";
}
}
if(lines[i].length() > 10)
{
if(lines[i].charAt(4) == '-' && lines[i+1].charAt(4) != '-' && !lines[i-1].equals("\nComment"))
{
lines[i] = "\nPost";
}
}
Your code does not check
lines[i+1]exists,lines[i-1]exists, andlines[i+1]is at least five.This would break when
iis zero orlines.length-1, or when one of the prior/next lines has less than five characters.