日期:2014-05-20  浏览次数:20657 次

j2me中读取res中的文本问题!!1
j2me中读取res中的文本如何实现读一行输出一行呢?以下是这个读取函数

public void resh()
{
InputStream in = null;
DataInputStream dis = null;
byte[] data = null;
int count;
//String[] txt1=null;
in=this.getClass().getResourceAsStream("/csbzm.txt");
dis = new DataInputStream(in);
try{
dis.mark(dis.available()+1);
count=dis.available();
dis.reset();
data = new byte[count];

for(int i=0;i<count;i++)
{
data[i]=dis.readByte();
}

}catch(Exception e){}
}
求解啊!


------解决方案--------------------
J2ME好像没有BufferedReader,所以你需要循环readByte出来后判断是否等于0x0A或0x0D(或两者连写),若是则换行。
------解决方案--------------------
dis读的文件要求必须是DataOutputStream输出成的文件才可以读的
------解决方案--------------------
把你的代码贴出来
------解决方案--------------------
先把mark和reset方法注释了,再测下