I am trying to read a file and hence I am splitting the fields when I receive ',' comma separator . However some fields have ',' in them but they are enclosed within double quotes hence how can I split it escaping the , separator.
Here is what I have done
String[] cols = line.split(Pattern.quote(","));
How should I modify this using split() only in Java. Also what changes will I have to make in case the separator is a pipe '|'?