001package serialization.custom;
002import java.io.FileInputStream;
003import java.io.FileNotFoundException;
004import java.io.FileOutputStream;
005import java.io.IOException;
006import java.io.ObjectInputStream;
007import java.io.ObjectOutputStream;
008import java.util.LinkedList;
009
010@SuppressWarnings("serial")
011class IntList1 implements IntList
012{
013        private LinkedList<Integer> v;
014        //private void setV(LinkedList<Integer> v) { v = v; }
015
016        public IntList1()               { v = new LinkedList<Integer>(); }
017        public void addBack(int i)      { v.addLast(i); }
018        public void addFront(int i)     { v.addFirst(i); }
019        public int removeFront()        { return v.removeFirst(); }
020        public int removeBack()         { return v.removeLast(); }
021        public boolean isEmpty()        { return v.size() == 0; }
022}
023
024public class Main1 {
025        public static void main(String[] args)
026                        throws IOException, FileNotFoundException, ClassNotFoundException
027        {
028                IntList L = new IntList1();
029                for (int i=0; i<1000; i++)
030                        L.addFront(i);
031
032                ObjectOutputStream os = new ObjectOutputStream (new FileOutputStream("out1.dat"));
033                os.writeObject(L);
034                os.flush();
035                os.close();
036
037                ObjectInputStream in = new ObjectInputStream (new FileInputStream("out1.dat"));
038                IntList V = (IntList) in.readObject();
039                in.close();
040        }
041}