J2ME Midlet exception: IOException reader reading invalid first byte

When I launch my MIDlet using the Java Wireless toolkit, the MIDlet works correctly, but when it tries to parse a text field, the following error occurs:

java.lang.RuntimeException: IOException reading reader invalid first byte 10010111
    at com.sun.cldc.i18n.Helper.byteToCharArray(+228)
    at com.sun.cldc.i18n.Helper.byteToCharArray(+9)
    at java.lang.String.<init>(+7)
    at z.a(+219)
    at z.a(+103)
    at DP4JPhone.a(+74)
    at DP4JPhone.a(+115)
    at DP4JPhone.commandAction(+120)
    at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+282)
    at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(+10)
    at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(+68)
    at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(+47)
    at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.handleVmEvent(+186)
    at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+57)

What is the problem?

I am using JWT 2.5.2_01

+3
source share
2 answers

The problem is resolved.

As McDowell mentioned earlier, the problem was encoding settings. The best way to overcome this problem is to declare encoding information from the WTK.

ktools.properties('workdir\wtklib\ktools.properties' 'workdir\wtklib\Linux\ktools.properties', ). :

microedition.encoding= *encoding*

ASCII:

microedition.encoding=ISO8859_1

(:

+3

, , :

  • String(byte[]) ( )
  • String(byte[], String)

, , , 10010111 ( , ).

byte char (, String) " " UTF-16. , " " .

+2

Source: https://habr.com/ru/post/1729911/


All Articles