The
substring
method does not modify the original string; instead, it returns a new string. Thus, the line
line.substring(3);
does not do anything. You probably want to write
line = line.substring(3);
instead, which allows to save the new string back into the original one.
But, the issue here seems to be that
3
is not a valid index into the string. You may want to test for the length before trying to truncate:
if (line.length() > 3)
{ line = line.substring(3); }
Java - String substring() Method example[
^]