高手帮忙:motorola手机中文显示,以及如何从网络上获取图象文件?
hfggg 2004-09-16 10:42:04 1.使用J2ME开发手机客户软件,服务器端使用ASP代码编程;
ASP测试代码:
<%
CODEPAGE = 936
Session.Codepage = 65001
Response.Write ("中国移动")
%>
J2ME客户端接收代码:
boolean error = false ;
HttpConnection conn = null;
InputStream is = null;
InputStreamReader isr = null ;
StringBuffer line = new StringBuffer("");
try {
conn = (HttpConnection)Connector.open(this.url);
is = conn.openInputStream();
isr = new InputStreamReader(is) ;
int ic ;
char ch ;
while( (ic = isr.read()) != -1 ) { line.append((char)ic) ; }
}catch (Exception e) {error = true ; }
finally {
try {if(conn!=null) conn.close(); }catch(Exception e){}
}
if(!error)
{ Alert al = new Alert("内容",line.toString(),null,AlertType.ALARM) ;
al.setTimeout(Alert.FOREVER) ;
Navigator.display.setCurrent(al) ;
}
手机上测试显示的内容中文为乱码,很多'口'字样字符;
如果服务器端不变,那么以上J2ME代码该如何改变?
2.在J2ME中,怎样从网络上直接下载图象文件:
比如url=http://172.20.117.21/TEST.PNG;
调用conn = (HttpConnection)Connector.open(url);获取图象数据。
拜托各位大侠了.