Chào các bạn! Vì nhiều lý do từ nay Truyen2U chính thức đổi tên là Truyen247.Pro. Mong các bạn tiếp tục ủng hộ truy cập tên miền mới này nhé! Mãi yêu... ♥

java omg

public Object[] toArray() {

        return new Object[] {mahang, tenhang, ngaynhap, ngayxuat, soluong, loinhuan};

    }

    private final File f = new File("HANGHOA.DAT");;

    public void writeFile(ArrayList<laixe> ghilist) throws IOException {

        try{

        if (!f.exists()) 

        {    

            f.createNewFile();

        }

        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f,true));

        oos.writeObject(ghilist);

        oos.close();

        }catch(Exception e){

            System.out.println("Loi ghi file");

        }

    }

    public ArrayList<laixe> readFile() throws IOException, ClassNotFoundException {

        if (!f.exists())

        {

            return new ArrayList<laixe> ();

        }

        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(f));

        return (ArrayList<laixe>) ois.readObject();

    }

public void taoBang() {

        DefaultTableModel m= (DefaultTableModel) tableHang.getModel();

        m.getDataVector().removeAllElements();

        m.fireTableDataChanged();

        for(hangHoa h: listHangHoa)

            m.addRow(new Object

                    [ ] {h.getMahang(),h.getTenhang()});

    }

Bạn đang đọc truyện trên: Truyen247.Pro

Tags: