J2me上的GPRS網(wǎng)絡(luò)接入點(diǎn)有兩個(gè),一個(gè)就是CMNET,一個(gè)就是CMWAP。一般移動(dòng)夢(mèng)網(wǎng),百寶箱就是掛在CMWAP上的。
CMNET就是一般的互聯(lián)網(wǎng)的網(wǎng)絡(luò)接入點(diǎn)。我們一般在SUN那里看到的J2ME實(shí)例代碼都是基于CMNET接入點(diǎn)的網(wǎng)絡(luò)下載。一般來(lái)說(shuō),CMNET可以連接所有的網(wǎng)絡(luò)站點(diǎn)。下面就是我在開(kāi)發(fā)仙劍的CMNET的下載資源包的代碼片斷。
/***************************************************************************
* 下載網(wǎng)絡(luò)文件
* @param url String 要下載的文件的地址URL
* @return byte[] 假如下載成功,返回文件的字節(jié)緩沖;
* 假如下載失敗,返回null
*/
public byte[] download_CMNET(String url) {
ContentConnection c;
InputStream is = null;
byte[] data = null;
try {
c= (ContentConnection)Connector.open("http://"+ServerName+"/"+url,Connector.READ,true);
is = c.openInputStream();
int dataLength = (int) c.getLength();
if (dataLength == -1) {
ByteArrayOutputStream bStrm = new ByteArrayOutputStream();
int ch;
while ( (ch = is.read()) != -1)
bStrm.write(ch);
data = bStrm.toByteArray();
bStrm.close();
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注