秀纳

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::
个在J2SE中十分钟即告完成的代码,在J2ME中花费了一个下午.是什么样的代码呢?
[要求]在游戏中读入文本形式存储的hints

[分析]
J2ME没有BufferReader,用InputStreamReader吧
既然没有BufferReader,也就不要奢望有readLine()了,自己慢慢循环吧

[源代码]
[code]
/* read hint-------------------------------------- */
/**
* This is the hints
* */
String[][] hintStr;

/**
* this specify the hint's show width
*/
final int hint_width = 8;

int hint_num;

public boolean readHint(int stage) {

if (stage > 0 && stage < 4) {
if (stage == 2) {
hint_num = 4;
} else {
hint_num = 3;
}
} else {
System.out.println("No this stage");
return false;
}

try {

String filename = "hint" + Integer.toString(stage);
InputStreamReader in = new InputStreamReader(get str.substring((z - 1) * hint_width);

}
System.out.println("hintStr[" + j + "][" + z + "]:"
+ hintStr[j][z]);
}
j++;
}

} catch (IOException e) {
System.out.println("Error");
}
return true;
}
[/code]
[总结]
程序要求很简单,一定有更好的办法来实现,结果参阅了大量资料,一无所获.
posted on 2006-10-06 10:23  秀纳  阅读(205)  评论(0)    收藏  举报