Метод getUniqueld (Order.java)
Листинг 5.9. Метод getUniqueld (Order.java)
synchronized private int getUniqueId() {
int id;
try {
ObjectInputStream in = new ObjectInputStream( new
FileInputStream( "orderID.txt" ) );
id = in.readInt();
}
catch( IOException e ) {
id = 1000;
}
try {
ObjectOutputStream out = new ObjectOutputStream( new
FileOutputStream( "orderID.txt" ) );
out.writeInt( id + 1 );
out.close();
}
catch( IOException e ) {
}
return id;
}
}
Содержание раздела