The following code is from http://blog.csdn.net/hellogv/. for reference, see the source!
Package hello; import javax. microedition. MIDlet. *; import javax. microedition. lcdui. *; import javax. microedition. io. *; import Java. io. *; public class MIDlet extends MIDlet {private display; Public MIDlet () {display = display. getdisplay (this);} public void Startapp () {try {string uurl = "http://3g.pp.cn/phone/app/gpcx.jsp? SID = 1182917775043 & dirid = 03311317 & gpdm = 600156 "; stringbuffer responsemessage = new stringbuffer (); httpconnection Hc = (httpconnection) connector. open (uurl, connector. read_write); HC. setrequestmethod (httpconnection. post); dataoutputstream dos = HC. opendataoutputstream (); datainputstream Dis = new datainputstream (HC. openinputstream (); // --------------------------- key code -------------------------------- byte [] STR = new byte [1000]; // apply for a space dis from the memory. read (STR); // Save the returned read information in STR string content = bytestostring (STR ); // convert STR to a string // --------------------------- key code -------------------------------- Form F = new form ("HTTP test"); F. append (content); display. setcurrent (f);} catch (exception e) {}} // ------------------------- key function ----------------------------- Public String bytestostring (byte [] REC) {// read bytearrayinputstream BAIS = new bytearrayinputstream (REC); datainputstream Dis = new datainputstream (BAIS); string BTS = NULL; try {BTS = new string (REC, "UTF-8"); BAIS. close (); DIS. close ();} catch (exception e) {e. printstacktrace ();} return BTS;} // ----------------------- key function ----------------------------- public void pauseapp () {} public void destroyapp (Boolean unconditional ){}}