All pastes #505294 Raw Edit

Stuff

public text v1 · immutable
·published 2007-05-23 14:21 UTC
rendered paste body
this is the error I get when trying to serialize with objectOutputStream;

java.io.NotSerializableException: items.Background
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: items.Background
 

public void saveMapObject()
    {
        try
        {
            FileOutputStream fos = new FileOutputStream("mapObjects.txt");
            ObjectOutputStream ous = new ObjectOutputStream(fos);
            ous.writeObject(new Background(this, 0, 0)); <------- I get the error on this line
            ous.close();
        }
        catch(FileNotFoundException e)
        {
            System.out.println(e);
        }
        catch(IOException e)
        {
            System.out.println(e);
        }
    }
    
    public void loadMapObjects()
    {    
        try
        {
            FileInputStream fis = new FileInputStream("mapObjects.txt");
            ObjectInputStream ois = new ObjectInputStream(fis);
            while((tempItem = (Item)ois.readObject())!=null)
            {
                itemVector.add(tempItem);
            }
            ois.close();
        }
        catch(FileNotFoundException e)
        {
            System.out.println(e);
        }
        catch(IOException e)
        {
            System.out.println(e);
        }
        catch(ClassNotFoundException e)
        {
            System.out.print(e);
        }
    }