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

📄 rmsstumblewriter.java

📁 一个基于PlaceLab的室内和室外的智能导航系统
💻 JAVA
字号:
package org.placelab.midp.stumbler;import javax.microedition.rms.RecordEnumeration;import javax.microedition.rms.RecordStore;import org.placelab.core.Measurement;import org.placelab.core.ShutdownListener;/** * Writes measurement data to the RMS * */public class RMSStumbleWriter implements StumblerListener,		ShutdownListener {		private boolean shutdown = false;	private RecordStore rms;	private String rmsName;		public RMSStumbleWriter() {		rms = null;	}		public void open() {		boolean create = true;		if(rmsName != null) {			create = false;		} else {	    	String[] records = RecordStore.listRecordStores();	    	if(records == null)	    		rmsName = "phoneStumbler-0-"+System.currentTimeMillis();	    	else 	    		rmsName = "phoneStumbler-"+records.length+"-"+System.currentTimeMillis();		}    	try {    		rms = RecordStore.openRecordStore(rmsName,create);  		    	} catch(Exception e) {    		e.printStackTrace();    	}	}			public RecordEnumeration getRecords() {		RecordEnumeration re = null;		try {			re = rms.enumerateRecords(null,null,false);		} catch(Exception e) {			e.printStackTrace();		}		return re;	}		public void shutdown() {		try {			if(rms != null)				rms.closeRecordStore();		} catch(Exception e) {			e.printStackTrace();		}	}	public void gotMeasurement(Measurement[] m) {		if (shutdown)			return;		synchronized (this) {			for (int i=0;i<m.length;i++) {				if(m[i] == null) continue;				//				String entry = m[i].toLogString();//				//write to the RMS here//				byte entryBytes[] = entry.getBytes();				byte entryBytes[] = m[i].toCompressedBytes();				try {					rms.addRecord(entryBytes, 0, entryBytes.length);				} catch (Exception e) {					e.printStackTrace();				}			}		}	}}

⌨️ 快捷键说明

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