Try the following:
String [] = data.split ("~", -1);
refer to Javadoc for the split method using two arguments for details.
When calling String.split (String), it calls String.split (String, 0) and discards the final empty lines (as the docs say) when calling String.split (String, n) with n <0, it will not throw anything.
user319198
source
share