MIDP 2.0

Relation to MIDP 1.0

Networking extensions

Networking is still based on the Connector.open class. Other types of connection are added

Packaging

Push Registry

Push registry pseudocode

Turning pseudocode to real code

GUI

Multi-media

MIDP 2.0 has a number of classes for handling multi-media

Media support

The CLDC device can tell you what protocols and what media types it can handle

Single tones

Tone sequences

Echo server

The following server uses ServerSocketConnection to listen to connections on port 8189. Each message that is received on this port is echo'ed back to the client

Echo client

This client connects to a server on port 8189 and sends two messages

Reading and writing on sockets

J2ME does not have the full range of IO classes that are in the J2SE. For example, it does not have BufferedReader and PrintStream that are useful for reading and writing lines of text. It only has InputStream, DataInputStream, OutputStream and DataOutputStream.

To read and write strings using In/OutputStream, you need to turn the strings into byte arrays


    InputStream in = ...;
    OutputStream out = ...;
    String msg = "hello";
    byte[] barray = msg.getBytes();
    out.write(barray);

    in.read(barray);
    msg = new String(barrray);

To read and write strings using DataIn/OutputStream, use the UTF methods


    DataInputStream din = ...;
    DataOutputStream dout = ...;

    String str = din.readUTF();
    dout.writeUTF(str);


Jan Newmarch (http://jan.newmarch.name)
jan@newmarch.name
Last modified: Wed Apr 28 20:09:28 EST 2004
Copyright ©Jan Newmarch