import javax.microedition.lcdui.*; import javax.microedition.midlet.*; import java.io.*; public class Main extends MIDlet implements CommandListener{ private Display display; private Form MainForm; private StringItem StrFromTxt; private Command CMD_EXIT = new Command("Выход", Command.EXIT, 1); public void Main(){} protected void destroyApp( boolean unconditional ) throws MIDletStateChangeException { exitApp(); } protected void pauseApp(){} protected void startApp() throws MIDletStateChangeException { if( display == null ) { initApp(); } } private void initApp() { display = Display.getDisplay(this); String str=getText("/config.ini"); int i0=0, i=0; i = str.indexOf("|",i0+1); String FormName=str.substring(i0,i); i0=i; i = str.indexOf("|",i0+1); String Year=str.substring(i0+1,i); i0=i; i = str.indexOf("|",i0+1); String Weight=str.substring(i0+1,i); StringItem SI2= new StringItem("Год: ",""+Year); StringItem SI3= new StringItem("Вес: ",""+Weight); MainForm = new Form(FormName); Font f1 = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_ITALIC, Font.SIZE_LARGE); MainForm.setCommandListener(this); MainForm.addCommand(CMD_EXIT); MainForm.append(SI2,f1); MainForm.append(SI3); display.setCurrent(MainForm); } public void exitApp() { notifyDestroyed(); } public void commandAction(Command c, Displayable d) { if (c == CMD_EXIT){exitApp();} } private String getText(String path) { DataInputStream dis = new DataInputStream(getClass().getResourceAsStream(path)); StringBuffer strBuff = new StringBuffer(); int ch = 0; try { while ((ch = dis.read()) != -1) { strBuff.append((char ) ((ch >= 0xc0 && ch <= 0xFF) ? (ch + 0x350) : ch)); } dis.close(); } catch (Exception e) { System.err.println("ERROR in getText() " + e); } return strBuff.toString(); } }