大家好!帮忙看看这个问题!前段时间小弟自学J2ME手机游戏开发之后,自己编写了一个手机小游戏!但是用WTK 2.5.2模拟器运行会抛出以下异常,非常迷惑!虽然自己也处理过不少异常,但这个异常还是第一次碰见!如果说是我自己处理的png图片有问题的话,但是用另一款模拟器KEmulator 1.00运行的话,却能正常运行,一个异常都没有!包括最下面那两个空指针异常也消失了!到底怎么回事儿?小弟百思不得其解!请各位高人指点一下!
Running with storage root C:\Documents and Settings\Administrator\j2mewtk\2.5.2\appdb\MediaControlSkin
Running with locale: Chinese_People's Republic of China.936
Running in the identified_third_party security domain
java.io.UTFDataFormatException: malformed input around byte 714
at java.io.DataInputStream.readUTF(Unknown Source)
at javax.imageio.stream.ImageInputStreamImpl.readUTF(Unknown Source)
at com.sun.kvem.png.PNGImageReader.parse_iTXt_chunk(PNGImageReader.java:447)
at com.sun.kvem.png.PNGImageReader.readMetadata(PNGImageReader.java:650)
at com.sun.kvem.png.PNGImageReader.readImage(PNGImageReader.java:1312)
at com.sun.kvem.png.PNGImageReader.read(PNGImageReader.java:1582)
at com.sun.kvem.midp.GraphicsBridge.loadImage(GraphicsBridge.java:2602)
at com.sun.kvem.midp.GraphicsBridge.createImageFromData(GraphicsBridge.java:2511)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.kvem.sublime.MethodExecution.process(MethodExecution.java:42)
at com.sun.kvem.sublime.SublimeExecutor.processRequest(SublimeExecutor.java:63)
at com.sun.kvem.sublime.SublimeExecutor.run(SublimeExecutor.java:25)
loadImage error
startApp threw an Exception
java.lang.NullPointerException
java.lang.NullPointerException
at role.Role.<init>(+517)
at role.Solder.<init>(+6)
at map.Map.<init>(+117)
at GameMain.<init>(+56)
at GameMidlet.startApp(+44)
at javax.microedition.midlet.MIDletProxy.startApp(+7)
at com.sun.midp.midlet.Scheduler.schedule(+270)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+80)
Execution completed.
3474582 bytecodes executed
43 thread switches
1706 classes in the system (including system classes)
21456 dynamic objects allocated (2079824 bytes)
35 garbage collections (928672 bytes collected)作者: ◇半度微凉 时间: 2011-12-8 13:58
{:soso_e127:}咋没人回答我的问题啊 作者: ◇半度微凉 时间: 2011-12-9 10:26
悲剧了!还是没人帮忙解答啊!{:soso_e109:} 自己顶一个吧!{:soso_e130:}作者: ◇半度微凉 时间: 2011-12-9 23:17
哎!这个问题放在这里快两天了!最终还是靠自己解决了,查了很多资料,也请教了别人,终于明白怎么回事儿了!拿出来与大家分享一下吧!
首先java.io.UTFDataFormatException: malformed input around byte 714这个属于Io异常,文件流读取错误!开始还以为是代码错误呢!后来经过多次试验才发现是因为我自己用PhotoShop处理图片的时候没有处理好,格式没保存好,所以WTK模拟器没办法正确识别这些图片,读取不出来,所以才会提示文件流读取错误这个Io异常,因为图片无法正常加载,所以才导致下面初始化图片的时候出现空指针异常!之所以KEmulator 1.00模拟器能正常运行,是因为KEmulator 1.00能识别这种这种格式,所以能正常运行!
终于解决掉这个问题了!挺高兴的!自己给自己顶一个吧!嘿嘿···{:soso_e130:}