private static void writeToFile(Serializable serializable)
    {
        FileOutputStream fout = null;
        ObjectOutputStream oos =null;
        try
        {
            fout = new FileOutputStream("triangle.ser");
            oos = new ObjectOutputStream(fout);
            oos.writeObject(serializable);
            oos.close();
            System.out.println("Done");
        } catch (IOException e)
        {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        finally
        {
            if (fout != null)
            {
                try
                {
                    fout.close();
                } catch (IOException e)
                {
                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                }
            }
            if( oos != null)
            {
                try
                {
                    oos.close();
                } catch (IOException e)
                {
                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                }
            }
        }
    }