I have an ArrayList W1 containing Ward type objects and each Ward object have a Ward Name,Max Capacity,Current Capacity and an ArrayList P1 containing Patient type objects. Each Patient type object have a Name,Age,Address,gender..etc
i want to write the ArrayList W1 to file using bufferedwriter and read that file using bufferedreader.
i do know how to read from an ArrayList and write to a file. but in this case it confusing me because i am trying to read from an ArrayList which contains objects with ArrayList.
Please tell me how to do this.
Thanks
is there any other ways rather than this,
public static void addWardToFile(Ward ward)
{
try
{
out = new BufferedWriter(new FileWriter("wardDetails.txt",true));
Iterator itr = ward.wardPatients.iterator();
String patient="";
while(itr.hasNext())
{
patient += itr.next().toString() + ":"; //patient object have a overridden toString method
}
out.write(ward.name +","+patients);
out.newLine();
out.close();
}