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.
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 ;)