I need to read a file with this format:
(w,x,y,z),(w,x,y,z), ... ,(w,x,y,z);
All on one line.
//edit:
I eventually will need to do this on files like the following as well:
(w,x,y,z_1 ... z_n),(w,x,y,z_1 ... z_n), ... ,(w,x,y,z_1 ... z_n);
so simply reading past 3 commas is not going to cut it.
My plan is to read the whole file into a String using the Scanner class, then splitting it up in an array of (w,x,y,z) parts and then splitting that up into the actual w, x, y and z. Eventually the data in the file would end up in a list of objects something like:
public class DataBean {
private String w, x, y, z;
...
}
I'm having trouble coming up with a regular expression for this though. I tried
String[] allSystems = scanner.nextLine ( ).split ( "),(" );
and sure, it cuts the string up, but I feel it's not the most elegant solution. If anyone has a better idea I'd love to hear!
String[] allSystems = scanner.nextLine ( ).split ( "),(" );is a very clean way to do it