codice:
public static LinkedList ReadInFile(String nomefile) {
		Object O = null;
		LinkedList l;
		l = new LinkedList();
		ObjectInputStream ois = null;
		try 
                {
			FileInputStream fis = new FileInputStream(nomefile);
			ois = new ObjectInputStream(fis);
		}
                catch (FileNotFoundException e)
                {
			System.out.println("file non found");
		}
                catch (IOException e1) 
                {
			System.out.println("IO problem 1");
		}
		try 
		{
		O = ois.readObject();
		l.addFirst(O);	
		while (O !=null)	
		O = ois.readObject();
		l.addFirst(O);
		} 
		catch (IOException e2) 
		{
			System.out.println("IO problem 2");
		} 
                catch (ClassNotFoundException e3)
		{
			System.out.println("class problem");
		}
		
		return l;
	}
qual è l'errore in questo metodo? mi va in IOException e2. credo l'errore sia while (O !=null), ma come leggere il file fino alla fine?