游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2166|回复: 1

关于MIDP输入输出的问题?????在线等待

[复制链接]

37

主题

68

帖子

68

积分

注册会员

Rank: 2

积分
68
发表于 2004-12-2 15:32:00 | 显示全部楼层 |阅读模式
代码如下 :
public void run() {

    try {
      InputStream is = this.getClass().getResourceAsStream("/cart.txt");
      InputStreamReader r = new InputStreamReader(is);
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
}
会出现异常:
java.lang.NullPointerException
        at com.sun.cldc.i18n.Helper.getStreamReader(+15)
        at com.sun.cldc.i18n.Helper.getStreamReader(+7)
        at java.io.InputStreamReader.<init>(+9)
        at test2.Canvas.run(+18)
但是如果改用:
try {
      InputStream is = this.getClass().getResourceAsStream("/cart.txt");
      DataInputStream r = new DataInputStream(is);
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
  }
就不会出现异常,这是为什么???高手指教

1

主题

10

帖子

10

积分

新手上路

Rank: 1

积分
10
QQ
发表于 2004-12-7 13:36:00 | 显示全部楼层

Re:关于MIDP输入输出的问题?????在线等待

MIDP下没有这样写的~~
InputStreamReader r = new InputStreamReader(is);
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-23 15:02

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表