I can write a list to a file with this code:
MyList<Integer> l = new MyList<Integer>();
//...
FileOutputStream fos = new FileOutputStream(filename);
ObjectOutputStream writer = new ObjectOutputStream(fos);
writer.writeObject(l);
writer.close();
Now I want to read the list from the file and I tried with this code:
MyList<Integer> list = new MyList<Integer>();
//...
FileInputStream fis = new FileInputStream(filename);
ObjectInputStream reader = new ObjectInputStream(fis);
list = (MyList<Integer>) reader.readObject();
reader.close();
But now I get a SuppressWarnings unchecked
from Eclipse and I have to check for a ClassNotFoundException. Why is that and how can I prevent this?