I am trying to obtain an array of Strings (dummy) which is to be converted to a custom object Combo, by splitting every String contained in a second array (readarray). This second array is obtained by splitting the contents of a file.
Even though the array obtained by splitting the file's contents seems to be working fine, I can't seem to successfully split the Strings it contains, I get one empty return (dummy[0]) and the ones after are null. Also, readFromFile() simply uses a FileInputStream to return the full String the file contains.
ArrayList<Combo> combos=new ArrayList<>();
String[] dummy;
String read=readFromFile();
String[] readarray=read.split("#");
for (String ss:readarray) {
dummy=ss.split("-");
Combo combo=new Combo(dummy[0],Integer.parseInt(dummy[1]),Integer.parseInt(dummy[2]),Integer.parseInt(dummy[3]));
combos.add(combo);
}
This is the String the file contains from which the above reads:
#22/09/2020-0900-2300-30#22/09/2020-0930-2330-30#22/09/2020-0900-2300-15
Help would be very much appreciated, thanks a lot.