高手帮忙: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);获取图象数据。

拜托各位大侠了.
...全文
180 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
hfggg 2004-09-20
  • 打赏
  • 举报
回复
OK,自己发现了答案:
ss=new String(STR.getBytes("ISO-8859-1"),"utf-8"))
hfggg 2004-09-20
  • 打赏
  • 举报
回复
up!
help me!
hfggg 2004-09-17
  • 打赏
  • 举报
回复
服务器端ASP中如何使用writeUTF?
AlexJava2 2004-09-17
  • 打赏
  • 举报
回复
DataInputStream
DataOutputStream

writeUTF

readUTF

中文问题就解决了

:)
hfggg 2004-09-17
  • 打赏
  • 举报
回复
怎么没人帮我呀!
hfggg 2004-09-16
  • 打赏
  • 举报
回复
自己顶一下
hfggg 2004-09-16
  • 打赏
  • 举报
回复
服务器测试文件代码改为
<%
CODEPAGE = 936
Response.Write ("中国移动")
%>
在J2ME Wireless Toolkit 2.0_01 上的默认调试器中中文显示正常,但在MOTO a760的模拟器以及在MOTO a768真手机上运行则汉字显示不对.但System.out.println(str)的输出完全正确.
经检测显示的内容好象是UTF-8编码格式;
但使用ss=new String(STR.getBytes("UTF-8"),"GB2312"))函数无效呀,

大家帮帮我呀!!
mingjava 2004-09-16
  • 打赏
  • 举报
回复
http://www.j2medev.com/Article_Show.asp?ArticleID=83
hfggg 2004-09-16
  • 打赏
  • 举报
回复
ashram(孤鸿):谢谢了.
ashram 2004-09-16
  • 打赏
  • 举报
回复
public Image getHttpConnectionImage() throws IOException
{
String url="http://172.20.117.21/TEST.PNG";
HttpConnection c = null;
InputStream is = null;
byte [] imgdata;
Image img;
try
{
c = (HttpConnection)Connector.open(url);
is = c.openInputStream();

// Get the length and process the data
int len = (int)c.getLength();
if (len > 0)
{
imgdata = new byte[len];
int actual = is.read(data);
img = Image.createImage(imgdata);
...
}
}
catch(Exception e)
{}
finally
{
if (is != null)
is.close();
if (c != null)
c.close();
}
return img;
}

13,097

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧