import javax.microedition.lcdui.Alert;import javax.microedition.lcdui.AlertType;import javax.microedition.lcdui.Display;import javax.microedition.midlet.MIDlet;import javax.microedition.midlet.MIDletStateChangeException;import javax.microedition.rms.RecordStoreException;public class RMSAnalyzer extends MIDlet{private Display display;private CounterCanvas counterCanvas;private Alert alert;protected void startApp()throws MIDletStateChangeException{display = Display.getDisplay(RMSAnalyzer.this);alert = new Alert("错误提示");try{String interval = this.getAppProperty("INTER");int t = Integer.parseInt(interval);counterCanvas =new CounterCanvas(t, 1, this);} catch (RecordStoreException e){this.showAlertError(e.getMessage());}display.setCurrent(counterCanvas);}public Display getDisplay(){return display;}protected void pauseApp(){}protected void destroyApp(boolean arg0) throwsMIDletStateChangeException{}public void showAlertError(String message){alert.setString(message);alert.setType(AlertType.ERROR);alert.setTimeout(3000);display.setCurrent(alert);}}import java.util.Timer;import java.util.TimerTask;import javax.microedition.lcdui.Canvas;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.CommandListener;import javax.microedition.lcdui.Displayable;import javax.microedition.lcdui.Graphics;import javax.microedition.midlet.MIDletStateChangeException;import javax.microedition.rms.*;public class CounterCanvas extends Canvas implements CommandListener{private RMSModel model;private RMSAnalyzer RMSanalyzer;private int interTime;private int counter;private boolean go = true;public static Command backCommand = new Command("退出", Command.EXIT, 3);public static final int INC = 1;public final Timer timer = new Timer();public CounterCanvas(int interTime,int base, RMSAnalyzer rmsa)throws RecordStoreException{this.interTime = interTime;this.counter = base;this.RMSanalyzer = rmsa;model = new RMSModel(base, RMSanalyzer);this.addCommand(backCommand);this.setCommandListener(this);TimerTask timerTask = new TimerTask(){public void run(){ try { model.writeRecord(INC); counter++; } catch (RecordStoreFullException e) { go = false; model.deleteRMS(); timer.cancel(); } catch (RecordStoreException e) { model.deleteRMS(); RMSanalyzer.showAlertError(e.getMessage()); timer.cancel(); } repaint();}};timer.schedule(timerTask, 1000, interTime);}public void setCounter(int counter){this.counter = counter;}public void setInterTime(int interTime){this.interTime = interTime;}protected void paint(Graphics arg0){int SCREEN_WIDTH = this.getWidth();int SCREEN_HEIGHT = this.getHeight();arg0.drawRect(SCREEN_WIDTH / 10,SCREEN_HEIGHT / 2, SCREEN_WIDTH * 4 / 5, 10);if(RMSanalyzer.getDisplay().isColor()){arg0.setColor(128, 128, 255);}arg0.fillRect(SCREEN_WIDTH / 10,SCREEN_HEIGHT / 2, counter, 10);if (!go)arg0.drawString("最大值:" + counter+"K字节", 0, 0,Graphics.TOP | Graphics.LEFT);}public void commandAction(Command arg0, Displayable arg1){if (arg0 == backCommand){try{