I have a case when I do the following:
final String[] columns = row.split(delimiter.toString());
Where delimiter is the symbol.
This works fine when I need to split based on tabs, providing \t as a delimiter. However, when I want to split into a channel, I pass the separator | , and it does not work properly.
I read a few posts on how | is a special character that means null or empty, so it breaks down into every character that it comes across, although I don't want this behavior.
I could do a simple check in my code for this case case and work around the problem:
if ("|".equals(delimiter.toString())) { columns = row.split("\\" + delimiter.toString()); } else { columns = row.split(delimiter.toString()); }
But I did not know if there is an easier way to get around this. Also, are there any other special characters that act like | What do I need to consider?
Dan w source share