I have this kind of file structure
MALE:FooBar:32 FEMALE:BarFoo:23
Where I would want to identify the gender and age of person, <Gender>:<Name>:<age>
try{
BufferedReader in = new BufferedReader(new FileReader("people.ser"));
String s;
while((s = in.readLine()) != null){
String[] var = s.split(":");
//var[0]=MALE etc etc
addGender.add(var[0]);
}
}catch(Exception e){
e.printStackTrace();
}
- Is using a delimiter (like a
:
in this case) to split string considered a bad practice? - What about using the array from the splitted string to store it in some place?
- Are there any alternatives and better file structure?