Previously, I have wrote a arraylist data into a binary file called (ItStateBinary.dat)
and now I am trying to read the arraylist from the binary file, then assign each of the element in arraylist to the array.
so far i have this:
public CarOwner[] readListFromBinary() throws Exception
{
String fileName = "ItStateBinary.dat";
FileInputStream inStream = new FileInputStream(fileName);
ObjectInputStream objectInputFile = new ObjectInputStream(inStream);
//need to create CarOwner[] object called temp and return
}
readListFromBinary() method Reads an ArrayList collection from a binary file (ltStateBinary.dat). Then, each ArrayList object item is then written to a newly created CarOwner[] called temp. temp is returned to the calling method.
edit:
public CarOwner[] readListFromBinary() throws Exception
{
String fileName = "ItStateBinary.dat";
FileInputStream inStream = new FileInputStream(fileName);
ObjectInputStream objectInputFile = new ObjectInputStream(inStream);
ArrayList<CarOwner> read = (ArrayList<CarOwner>)objectInputFile.readObject();
CarOwner[] temp = read.toArray(new CarOwner[read.size()]);
return temp;
}
does anybody know whats wrong with this method? it gives me compiler warning