package com.qst.dms.entity;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class AppendObjectOutputStream extends ObjectOutputStream
{
    public static File file = null;
    public AppendObjectOutputStream() throws IOException
    {
        super(new FileOutputStream(file,true));
        //AppendObjectOutputStream.file = file; 这不可行 因为 上面的构造函数调用了writeStreamHeadler 然后file=null 所以需要在外部提前赋值
    }
    public void writeStreamHeader() throws IOException
    {
        if(file!=null)
        {
            if (file.length() == 0)
                super.writeStreamHeader();
            else
            {
                //super.
                this.reset();
            }
        } else
            super.writeStreamHeader();
    }
}
