{"id":322,"date":"2007-10-17T00:00:00","date_gmt":"2007-10-17T00:00:00","guid":{"rendered":"http:\/\/www.strongd.net\/?p=322"},"modified":"2007-10-17T00:00:00","modified_gmt":"2007-10-17T00:00:00","slug":"J2ME : Read Display File","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=322","title":{"rendered":"J2ME : Read Display File"},"content":{"rendered":"<p><FONT face=\"Courier New\"><FONT color=#7f0055><STRONG>import&nbsp;<\/STRONG><\/FONT><FONT color=#000000>javax.microedition.midlet.*;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>javax.microedition.lcdui.*;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>java.io.*;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>public&nbsp;class&nbsp;<\/B><\/FONT><FONT color=#000000>ReadDisplayFile&nbsp;<\/FONT><FONT color=#7f0055><B>extends&nbsp;<\/B><\/FONT><FONT color=#000000>MIDlet&nbsp;<\/FONT><FONT color=#7f0055><B>implements&nbsp;<\/B><\/FONT><FONT color=#000000>CommandListener<\/FONT><BR><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>private&nbsp;<\/B><\/FONT><FONT color=#000000>Display&nbsp;display;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/&nbsp;Reference&nbsp;to&nbsp;Display&nbsp;object<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>private&nbsp;<\/B><\/FONT><FONT color=#000000>Form&nbsp;fmMain;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/&nbsp;Main&nbsp;form<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>private&nbsp;<\/B><\/FONT><FONT color=#000000>Command&nbsp;cmHelp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/&nbsp;Command&nbsp;to&nbsp;show&nbsp;a&nbsp;help&nbsp;file<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>private&nbsp;<\/B><\/FONT><FONT color=#000000>Command&nbsp;cmExit;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/&nbsp;Command&nbsp;to&nbsp;exit&nbsp;the&nbsp;MIDlet<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>private&nbsp;<\/B><\/FONT><FONT color=#000000>Alert&nbsp;alHelp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/&nbsp;Alert&nbsp;to&nbsp;display&nbsp;help&nbsp;file&nbsp;text<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#000000>ReadDisplayFile<\/FONT><FONT color=#000000>()<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>display&nbsp;=&nbsp;Display.getDisplay<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#7f0055><B>this<\/B><\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>cmHelp&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>Command<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Help&#8221;<\/FONT><FONT color=#000000>,&nbsp;Command.SCREEN,&nbsp;<\/FONT><FONT color=#990000>1<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>cmExit&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>Command<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Exit&#8221;<\/FONT><FONT color=#000000>,&nbsp;Command.EXIT,&nbsp;<\/FONT><FONT color=#990000>1<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>fmMain&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>Form<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Read&nbsp;File&#8221;<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>fmMain.addCommand<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>cmExit<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>fmMain.addCommand<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>cmHelp<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>fmMain.setCommandListener<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#7f0055><B>this<\/B><\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#7f0055><B>void&nbsp;<\/B><\/FONT><FONT color=#000000>startApp<\/FONT><FONT color=#000000>()<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>display.setCurrent<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>fmMain<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#7f0055><B>void&nbsp;<\/B><\/FONT><FONT color=#000000>pauseApp<\/FONT><FONT color=#000000>()<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>{&nbsp;}<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#7f0055><B>void&nbsp;<\/B><\/FONT><FONT color=#000000>destroyApp<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#7f0055><B>boolean&nbsp;<\/B><\/FONT><FONT color=#000000>unconditional<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>{&nbsp;}<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#7f0055><B>void&nbsp;<\/B><\/FONT><FONT color=#000000>commandAction<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Command&nbsp;c,&nbsp;Displayable&nbsp;s<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>if&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>c&nbsp;==&nbsp;cmHelp<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>String&nbsp;str;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/&nbsp;Access&nbsp;the&nbsp;resource&nbsp;and&nbsp;read&nbsp;its&nbsp;contents<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>if&nbsp;<\/B><\/FONT><FONT color=#000000>((<\/FONT><FONT color=#000000>str&nbsp;=&nbsp;readHelpText<\/FONT><FONT color=#000000>())&nbsp;<\/FONT><FONT color=#000000>!=&nbsp;<\/FONT><FONT color=#7f0055><B>null<\/B><\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/&nbsp;Create&nbsp;an&nbsp;Alert&nbsp;to&nbsp;display&nbsp;the&nbsp;help&nbsp;text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>alHelp&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>Alert<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Help&#8221;<\/FONT><FONT color=#000000>,&nbsp;str,&nbsp;null,&nbsp;<\/FONT><FONT color=#7f0055><B>null<\/B><\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>alHelp.setTimeout<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Alert.FOREVER<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>display.setCurrent<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>alHelp,&nbsp;fmMain<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>else&nbsp;if&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>c&nbsp;==&nbsp;cmExit<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>destroyApp<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#7f0055><B>false<\/B><\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>notifyDestroyed<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>private&nbsp;<\/B><\/FONT><FONT color=#000000>String&nbsp;readHelpText<\/FONT><FONT color=#000000>()<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>InputStream&nbsp;is&nbsp;=&nbsp;getClass<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>.getResourceAsStream<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;help.txt&#8221;<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>try&nbsp;<\/B><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>StringBuffer&nbsp;sb&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>StringBuffer<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>int&nbsp;<\/B><\/FONT><FONT color=#000000>chr,&nbsp;i&nbsp;=&nbsp;<\/FONT><FONT color=#990000>0<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#3f7f5f>\/\/&nbsp;Read&nbsp;until&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;stream&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>while&nbsp;<\/B><\/FONT><FONT color=#000000>((<\/FONT><FONT color=#000000>chr&nbsp;=&nbsp;is.read<\/FONT><FONT color=#000000>())&nbsp;<\/FONT><FONT color=#000000>!=&nbsp;&#8211;<\/FONT><FONT color=#990000>1<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>sb.append<\/FONT><FONT color=#000000>((<\/FONT><FONT color=#7f0055><B>char<\/B><\/FONT><FONT color=#000000>)&nbsp;<\/FONT><FONT color=#000000>chr<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>return&nbsp;<\/B><\/FONT><FONT color=#000000>sb.toString<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>catch&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Exception&nbsp;e<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>System.out.println<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Unable&nbsp;to&nbsp;create&nbsp;stream&#8221;<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>return&nbsp;null<\/B><\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#000000>}<\/FONT><\/FONT><BR><br \/>\n<DIV><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>import&nbsp;javax.microedition.midlet.*;import&nbsp;javax.microedition.lcdui.*;import&nbsp;java.io.*;public&nbsp;class&nbsp;ReadDisplayFile&nbsp;extends&nbsp;MIDlet&nbsp;implements&nbsp;CommandListener{&nbsp;&nbsp;private&nbsp;Display&nbsp;display;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;Reference&nbsp;to&nbsp;Display&nbsp;object&nbsp;&nbsp;private&nbsp;Form&nbsp;fmMain;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;Main&nbsp;form&nbsp;&nbsp;private&nbsp;Command&nbsp;cmHelp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;Command&nbsp;to&nbsp;show&nbsp;a&nbsp;help&nbsp;file&nbsp;&nbsp;private&nbsp;Command&nbsp;cmExit;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;Command&nbsp;to&nbsp;exit&nbsp;the&nbsp;MIDlet&nbsp;&nbsp;private&nbsp;Alert&nbsp;alHelp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;Alert&nbsp;to&nbsp;display&nbsp;help&nbsp;file&nbsp;text&nbsp;&nbsp;public&nbsp;ReadDisplayFile()&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;display&nbsp;=&nbsp;Display.getDisplay(this);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmHelp&nbsp;=&nbsp;new&nbsp;Command(&#8220;Help&#8221;,&nbsp;Command.SCREEN,&nbsp;1);&nbsp;&nbsp;&nbsp;&nbsp;cmExit&nbsp;=&nbsp;new&nbsp;Command(&#8220;Exit&#8221;,&nbsp;Command.EXIT,&nbsp;1);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fmMain&nbsp;=&nbsp;new&nbsp;Form(&#8220;Read&nbsp;File&#8221;);&nbsp;&nbsp;&nbsp;&nbsp;fmMain.addCommand(cmExit);&nbsp;&nbsp;&nbsp;&nbsp;fmMain.addCommand(cmHelp);&nbsp;&nbsp;&nbsp;&nbsp;fmMain.setCommandListener(this);&nbsp;&nbsp;}&nbsp;&nbsp;public&nbsp;void&nbsp;startApp()&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;display.setCurrent(fmMain);&nbsp;&nbsp;}&nbsp;&nbsp;public&nbsp;void&nbsp;pauseApp()&nbsp;&nbsp;{&nbsp;}&nbsp;&nbsp;public&nbsp;void&nbsp;destroyApp(boolean&nbsp;unconditional)&nbsp;&nbsp;{&nbsp;}&nbsp;&nbsp;public&nbsp;void&nbsp;commandAction(Command&nbsp;c,&nbsp;Displayable&nbsp;s)&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(c&nbsp;==&nbsp;cmHelp)&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;str;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;Access&nbsp;the&nbsp;resource&nbsp;and&nbsp;read&nbsp;its&nbsp;contents&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;((str&nbsp;=&nbsp;readHelpText())&nbsp;!=&nbsp;null)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;Create&nbsp;an&nbsp;Alert&nbsp;to&nbsp;display&nbsp;the&nbsp;help&nbsp;text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alHelp&nbsp;=&nbsp;new&nbsp;Alert(&#8220;Help&#8221;,&nbsp;str,&nbsp;null,&nbsp;null);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alHelp.setTimeout(Alert.FOREVER);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;display.setCurrent(alHelp,&nbsp;fmMain);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(c&nbsp;==&nbsp;cmExit)&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;destroyApp(false);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;notifyDestroyed();&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;String&nbsp;readHelpText()&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;InputStream&nbsp;is&nbsp;=&nbsp;getClass().getResourceAsStream(&#8220;help.txt&#8221;);&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StringBuffer&nbsp;sb&nbsp;=&nbsp;new&nbsp;StringBuffer();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;chr,&nbsp;i&nbsp;=&nbsp;0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;Read&nbsp;until&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;stream&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;((chr&nbsp;=&nbsp;is.read())&nbsp;!=&nbsp;&#8211;1)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sb.append((char)&nbsp;chr);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;sb.toString();&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;catch&nbsp;(Exception&nbsp;e)&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&#8220;Unable&nbsp;to&nbsp;create&nbsp;stream&#8221;);&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;null;&nbsp;&nbsp;}}<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-322","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=322"}],"version-history":[{"count":0,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/322\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}