You need to avoid lines: | - a special character in regular expression.
Using:
for(String s : line.split("\\|\\|##")) {
Alternatively, you can use \Q\E to force the use of the whole pattern:
for(String s : line.split("\\Q||##\\E")) {
This is probably the same pattern that you will get from Pattern.quote .
| allows you to specify additional patterns in the regular expression. Your regex is equivalent to |## , or: nothing OR ##. It splits around an empty string or between each character in the input.
See javadoc for Pattern .
source share