⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datastore.java

📁 This Source.zip has three application code folders containing .java and .class files and two .jar fi
💻 JAVA
字号:

import javax.microedition.rms.RecordStore;

public class DataStore
{

    private RecordStore recStore = null;
    
    public DataStore(String storeName) {
        try { 
            recStore = RecordStore.openRecordStore ( storeName, true ); 
        } catch ( Exception e ) {
            e.printStackTrace();
        } 
    }//DataStore

     
    public void deleteStore(String storeName) {
        try{
        	recStore.closeRecordStore();  
            RecordStore.deleteRecordStore(storeName);
        } catch ( Exception e ) { 
            e.printStackTrace();
        } 
    }//deleteStore()    
        
    
    public void setRecord (long time, String pipeId) {
        
        String record = (Long.toString(time)) +"@"+ pipeId;
        try {
            recStore.addRecord ( record.getBytes(), 0, record.getBytes().length );
            recStore.closeRecordStore();            
        } catch ( Exception e ){
            e.printStackTrace();
        }
                         
    }//setRecord()
    

    public long getAdvPublishTime() {
        long timeInMillis = 0L;
        try {
            if ( recStore.getNumRecords() > 0 )
            {
                String record = new String( recStore.getRecord (1) );
                int index = record.indexOf("@");
                timeInMillis = Long.parseLong( record.substring (0,index) );
            }
        
        }//try
        catch (Exception e)
        {
            e.printStackTrace();
        }//catch

        return timeInMillis;

    }//getAdvPublishTime() 
    

    public String getPipeId() {
        try
        {
            if ( recStore.getNumRecords() > 0 ) {
                String record = new String( recStore.getRecord (1) );
                int index = record.indexOf("@");
                String pipeId = record.substring (index+1,record.length());
                return pipeId;
            }//if ( recStore.getNumRecords() > 0)
        
        }//try
        catch (Exception e)
        {
            e.printStackTrace();
        }//catch
        
        return null;
    }//getPipeId ()

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -