Files
project-unisa-for-shop-mana…/it/unisa/info13d/Utility/IdCounter.java

42 lines
1.1 KiB
Java

package it.unisa.info13d.Utility;
import it.unisa.info13d.Articoli.Global;
import it.unisa.info13d.Login.Entry;
import java.io.*;
import java.util.ArrayList;
/**
* Created with xgiovio.macbookair.
* User: xgiovio
* Date: 18/12/13
* Time: 00:41
*/
public class IdCounter {
public static void save_counter() throws FileNotFoundException,IOException,ClassNotFoundException{
File f_data = new File("id_counter");
Integer data = Integer.valueOf(Global.getGeneral_counter());
ObjectOutputStream writer = new ObjectOutputStream(new FileOutputStream(f_data));
writer.writeObject(data);
writer.close();
}
public static void restore_counter() throws FileNotFoundException,IOException,ClassNotFoundException{
File f_data = new File("id_counter");
if ( (f_data.exists())){
ObjectInputStream reader = new ObjectInputStream(new FileInputStream(f_data));
Integer data = (Integer) reader.readObject();
Global.setGeneral_counter(data.intValue());
}else{
Global.setGeneral_counter(0);
}
}
}