public void run() {
while (!exit) {
synchronized(parent) {
while(!commandAvailable) {
try {
parent.wait();
}
catch (InterruptedException e) {
}
}
}
commandAvailable = false;
switch (menu.getSelectedIndex()) {
case 0:
getDate();
break;
case 1:
exit = true;
}
}
destroyApp(false);
notifyDestroyed();
}
public void getDate() {
try {
socket =
(StreamConnection)Connector.open(dayTimeURL,
Connector.READ, true);
is = socket.openInputStream();
}
catch (Exception e) {
}
try {
int b;
StringBuffer sb = new StringBuffer();
while ( (b = is.read()) != -1) {
sb.append((char)b);
}
socket.close();
dt.setText(sb.toString());
display.setCurrent(outputForm);
}
catch (Exception e) {
}
}
}
}
你需要在jad文件中定义两个属性值,当然你也可以直接写在源代码中
DAYTIME_PORT: 13
HOST: 127.0.0.1