有没有办法在设备上增加Java ME的堆大小?我正在为诺基亚N95开发一个应用程序,但是当我尝试对更大的图像进行图像处理时会遇到内存问题.手机有足够的堆空间,但似乎限制Java ME允许使用的数量为1MB.
我正在尝试读取资源(asdf.txt),但如果文件大于5000字节,(例如)将4700个空字符插入到内容变量的末尾.有没有办法删除它们?(或设置正确的缓冲区大小?)
这是代码:
String content = "";
try {
InputStream in = this.getClass().getResourceAsStream("asdf.txt");
byte[] buffer = new byte[5000];
while (in.read(buffer) != -1) {
content += new String(buffer);
}
} catch (Exception e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud) 在为J2ME编写游戏时,我们遇到了一个使用java.lang.Integer.parseInt()的问题
我们有几个常量值定义为十六进制值,例如:
CHARACTER_RED = 0xFFAAA005;
Run Code Online (Sandbox Code Playgroud)
在游戏过程中,值被序列化并通过网络连接接收,作为十六进制值的字符串表示形式.为了将其解析回int,我们不成功地尝试了以下内容:
// Response contains the value "ffAAA005" for "characterId"
string hexValue = response.get("characterId");
// The following throws a NumberFormatException
int value = Integer.parseInt(hexValue, 16);
Run Code Online (Sandbox Code Playgroud)
然后我运行了一些测试并尝试了这个:
string hexValue = Integer.toHexString(0xFFAAA005);
// The following throws a NumberFormatException
int value = Integer.parseInt(hexValue, 16);
Run Code Online (Sandbox Code Playgroud)
这是实际代码的例外:
java.lang.NumberFormatException: ffaaa005
at java.lang.Integer.parseInt(Integer.java:462)
at net.triadgames.acertijo.GameMIDlet.startMIDlet(GameMIDlet.java:109)
Run Code Online (Sandbox Code Playgroud)
我必须承认,这让我感到困惑.查看parseInt代码,当被解析的数字"越过""负/正边界"时,似乎抛出了NumberFormatException(也许有人可以用右边的行话来编辑?).
这是Integer.parseInt函数的预期行为吗?最后我不得不编写自己的十六进制字符串解析函数,我对提供的实现非常不满意.
换句话说,我期望让Integer.parseInt()在整数误导的十六进制字符串表示上工作吗?
编辑:在我最初的帖子中,我写了0xFFFAAA005而不是0xFFAAA005.我已经纠正了这个错误.
我为黑莓做了简单的java应用程序,同时构建我的跟踪错误.
"Building Hisantosh
C:\BlackBerryJDE4.5.0\bin\rapc.exe -quiet import=..\lib\net_rim_api.jar codename=Hisantosh Hisantosh.rapc warnkey=0x52424200;0x52525400;0x52435200
"C:\Documents and Settings\Santosh\My Documents\Downloads\greetingscreen.java"
"C:\Documents and Settings\Santosh\My Documents\Downloads\helloworld.java"
I/O Error: Cannot run program "javac": CreateProcess error=2, The system cannot find the file specified
Error while building project "
Run Code Online (Sandbox Code Playgroud)
我已经设置了所有路径变量.
是否可以使用J2ME或BlackBerry API将对象序列化为字符串或字节数组?
谢谢.
我有以下描述的jad文件
MIDlet-Jar-Size: 404071
MIDlet-Jar-URL: test.jar
MIDlet-Name: test
MIDlet-Vendor: Vendor
MIDlet-Version: 1.0.1
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0
MicroEdition-test: test
Run Code Online (Sandbox Code Playgroud)
如何MIDlet-Version通过代码?
我尝试过System.getProperty("MIDlet-Version"),但它返回null.
我正在尝试将我的LWUIT应用程序移植到Codename.
我在LWUIT中使用过RMS,现在显然我必须将其转换为存储.
我不明白Storage类如何在Codename中工作,而codename的文档也没有任何关系.
1)存储文件的结构是什么?
- >在J2ME中RecordStore,您将记录像表一样捆绑在一起.每一行,对应一条记录.每条记录都有唯一的记录ID,您可以使用此记录ID访问记录.每条记录都可以存储一些数据.
这如何映射到Storage类?
2)我希望在我的存储中存储一些记录,我该怎么做?
文件说:
static Storage getInstance()
Returns the storage instance or null if the storage wasn't initialized using a call to init(String) first.
Run Code Online (Sandbox Code Playgroud)
- >在LWUIT中,它就像Storage.init(storageName).; 但是,没有一个代号为init的init!如何在Codename中打开存储?
3)如果我尝试打开一个不存在的存储文件,会发生什么(RMS给出例外)?
我是J2ME的新手.
在我的应用程序中,我想在记录存储中添加多个记录,并且还想访问它.
如何在记录存储中添加多个记录以及如何访问它?
我有一个字符串变量包含文本行
line1(Contains String)
line2(Contains String)
line3(Contains String)
line4(Contains String)
Run Code Online (Sandbox Code Playgroud)
我的要求是得到最后一行文字?
有人可以帮忙吗?
我意识到这还不是100%相关,但我对此非常好奇.在JDK8中,不推荐使用javac参数"source"和"target",并且将在JDK9中删除它们.作为一名JavaME开发人员,我想知道如何能够以旧平台为目标.例如,我在开发Blu-ray时使用的是目标1.3.如果没有"目标"选项,如何在JDK9退出时编译我的Xlet for Blu-ray?我想也必须有其他人(虽然我们可以同意不多)人们仍然需要针对旧设备.当JDK9出局时我们该怎么办?
编辑:甚至可以用JDK9定位1.3?