看板 java 關於我們 聯絡資訊
我用書中的範例在WTK裡run..確出現以下訊息 ConnectorDemo wants to send and receive data using the network. this will use airtime and may result in charges. is it ok to use airtime? 這要怎麼解決阿 ?? 範例如下: public ConnectorDemo() // 屬性、元件、初值設定(初始化) { display = Display.getDisplay(this); exitCommand = new Command("離開", Command.EXIT, 1); connCommand = new Command("連線", Command.OK, 1); } public void startApp() // 程式進入點 { showForm =new Form("HTTP 連線"); showForm.append(new String("請按「連線」鍵") ); showForm.addCommand(exitCommand); showForm.addCommand(connCommand); showForm.setCommandListener(this); display.setCurrent(showForm); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command c, Displayable s) // 各事件處理函數 { if(c==connCommand) { String showStr=""; HttpConnection httpConn = null; try // 開啟連線 { httpConn = (HttpConnection)Connector.open("http://127.0.0.1:8080/index.htm"); if( httpConn.getResponseCode() == HttpConnection.HTTP_OK) showStr = "連線成功!"; else showStr = "連線失敗!"; } catch(Exception O) { showStr = O.getMessage(); } try // 關閉連線 { if(httpConn != null) httpConn.close(); } catch(Exception O) { showStr = O.getMessage(); } // 將連線狀態顯示在 Alert 物件上 Alert alert = new Alert("連線狀態", showStr, null, AlertType.INFO); alert.setTimeout( Alert.FOREVER ); display.setCurrent( alert ); } if(c==exitCommand) { destroyApp(false); notifyDestroyed(); } } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.223.212.177