This content has been marked as final. Show 3 replies
- find out how to iterate over individual lines of a text file.
- read Java API how to check if a String starts with a certain substring or how regular expressions can help.
- if you found a line starting with '#' remember that fact in a boolean type variable.
- after processing the next line reset that boolean type variable.
- print lines only if that boolean type variable is true.
use an if clause and check the first character of the line... if it's a '#' then print it and the next one too.
Once you get it working, you should also consider edge conditions:
1: what if the current and next line both start with #
2: what if the last line in the file starts with #, and since its the last line, there is no line after it.
3: what if the file contains no lines that start with #.
Sorry about complicating your life, but a guy's got to have a hobby ;)