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: TruyenTop.Vip