View RSS Feed

My Java Tips

MIDP packages

Rate this Entry
by , 11-22-2011 at 05:53 PM (926 Views)
MIDP provides a standard run-time environment that allows new applications and services to be deployed dynamically on end-user devices like cellular phones and pagers. The MIDP is built upon CLDC (Connected Limited Device Configuration).


MIDP is an industry-standard profile for mobile devices and it is not dependent on a specific vendor. It is a provides foundation for mobile application development. MIDP contains following 3 core CLDC packages:

java.lang
java.io
java.util

Apart from this, MIDP provides following three MIDP-specific packages:

javax.microedition.io
javax.microedition.lcdui
javax.microedition.midlet
javax.microedition.rms

Lets first talk about java.lang CLDC package. Its a subset of the J2SE java.lang package but with few omissions. Floating point (Float) and double precision (Double) classes are omitted. There are several other classes that are omitted from the CLDC API, including ClassLoader, Compiler, InheritableThreadLocal, Number, Package, Process, RuntimePermission, SecurityManager, StrictMath, ThreadGroup, ThreadLocal, and Void. Do remember that Runnable interface, the Exception, Error classes are supported.

CLDC java.lang core classes are as follows:
Class, Object, Runtime, System, Thread, Throwable

The data types supported by java.lang package are:
Boolean, Byte, Character, Integer, Long, Short

Helper classes provided by CLDC java.lang package are:
Math, String and StringBuffer.
The CLDC java.io package contains many of the standard J2SE io package classes. Following are CLDC java.io input classes:

- ByteArrayInputStream – It is used to read bytes from inputstream in to a buffer

- DataInput – Its an interface that is used (its implementations) to read bytes from a binary input stream. After reading, the bytes are translated into primitive Java data types.

- DataInputStream- It provides an implementation of DataInput interface.

- DataInputStream – It is used to read primitive Java data types from the underlying input stream in a platform-independent way.

- InputStream – Its an abstract class that is the superclass of all classes representing an input stream of bytes.

- InputStreamReader – It is used to reads bytes and translates them into characters according to a specified character encoding.

- Reader – Its an abstract class for reading character streams.

InputStream classprovides following methods:

Java Code:
public int available() throws IOException
public void close() throws IOException
public void mark(int readlimit)
public boolean markSupported()
abstract public int read() throws IOException
public int read(byte[] b) throws IOException
public int read(byte[] b, int off, int len) throws IOException
public void reset() throws IOException
public long 	skip(long n) throws IOException


Following are CLDC java.io output classes:

- ByteArrayOutputStream - It implements an output stream where data is written into a bytes array.

- DataOutput – It is simply an interface which provides (its implementation) writing primitive Java data types to a binary output stream support

- DataOutputStream – It is an implementation of DataOutput interface.

- DataOutputStream – It is an output stream that allows an application to write primitive Java data types in a portable way.

- OutputStream - It is an abstract class that is the superclass of all classes representing an output stream of bytes.

- OutputStreamReader - This takes characters and translates them into bytes according to a specified character encoding.

- PrintStream – It is used to add a convenient way to print a textual representation of data values.

- Writer – Write is an abstract class and is used for writing character streams.

The utility package is also available in CLDC and it contains the most frequently used classes from the J2SE java.util package. There exist following 4 collection classes and 1 interface:

- Enumeration – Its an interface which allows us to iterate through a collection of items, one at a time.

- Hashtable – It implements hashtable interface and maps keys to values.

- Stack - Last-in-first-out (LIFO) collection or stack of objects.

- Vector – A list which can store objects.

CLDC java.util also provides support for date and time classes apart from Random class.

- Calendar - Calendar class is an abstract class for getting and setting dates.

- Date – Date class represents a specific date and time. It can represent a Date with millisecond precision.

- Random – Random class is a utility class and is used to generate a stream of random int or long values.

- TimeZone – It’s a very useful class that is used to change the data time stamp to different zones. It also handles daylight savings adjustments.

Submit "MIDP packages" to Facebook Submit "MIDP packages" to Digg Submit "MIDP packages" to del.icio.us Submit "MIDP packages" to StumbleUpon Submit "MIDP packages" to Google

Comments