Java Reference
In-Depth Information
try {
String baseURL = "http://65.215.221.148:8080/wj2/jargoneer?word=";
String url = baseURL + word;
mProgressString.setText("Connecting...");
hc = (HttpConnection)Connector.open(url);
hc.setRequestProperty("Connection", "close");
in = hc.openInputStream();
mProgressString.setText("Reading...");
int contentLength = (int)hc.getLength();
if (contentLength == -1) contentLength = 255;
byte[] raw = new byte[contentLength];
int length = in.read(raw);
// Clean up.
in.close();
hc.close();
definition = new String(raw, 0, length);
}
finally {
try {
if (in != null) in.close();
if (hc != null) hc.close();
}
catch (IOException ignored) {}
}
return definition;
}
}
Compiling a MIDlet
Writing MIDlets is an example of cross-compiling, where you compile code on one platform
and run it on another. In this case, you'll be compiling a MIDlet using J2SE on your desktop
computer. The MIDlet itself will run on a mobile phone, pager, or other mobile information
device that supports MIDP.
The J2ME Wireless Toolkit takes care of the details as long as you put the source code in the
right directory.
Start the toolkit, called KToolbar .
1.
2.
Choose New Project from the toolbar to create a new project.
Search WWH ::




Custom Search