FileDocCategorySizeDatePackage
StockDB.javaAPI DocExample1680Sat Jan 05 11:47:02 GMT 2002None

StockDB

public class StockDB extends Object

Fields Summary
RecordStore
recordStore
Constructors Summary
public StockDB()

     
public StockDB(String fileName)

      try {
         recordStore = RecordStore.openRecordStore(fileName, true);
      } catch(RecordStoreException rse) {
         rse.printStackTrace();
      }
   
Methods Summary
public synchronized voidaddNewStock(java.lang.String record)

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      DataOutputStream outputStream = new DataOutputStream(baos);
      try {
         outputStream.writeUTF(record);
      } catch (IOException ioe) {
         System.out.println(ioe);
         ioe.printStackTrace();
      }
      byte[] b = baos.toByteArray();
      try {
         recordStore.addRecord(b, 0, b.length);
      } catch (RecordStoreException rse) {
         System.out.println(rse);
         rse.printStackTrace();
      }
   
public voidclose()

      if (recordStore.getNumRecords() == 0) {
         String fileName = recordStore.getName();
         recordStore.closeRecordStore();
         recordStore.deleteRecordStore(fileName);
      } else {
         recordStore.closeRecordStore();
      }
   
public synchronized RecordEnumerationenumerate()

      return recordStore.enumerateRecords(null, null, false);