private void read()
{
byte[] data = null;
inputstream in=null;
datainputstream dis = null;
int count=0;//文本文件中字节的个数
int highpostion=-1,lowpostion=-1;//分别代表一个数字的十位数字和各位数字。
int num=0;//所得到的数字
int numcount=0;
try
{
in=this.getclass().getresourceasstream("/help.txt");//将位于res目录下的help.txt中数字读出。
dis = new datainputstream(in);
dis.mark(0);
while(true)
{
if(dis.read()!=-1)
{
count++;
}
else
{
break;
}
}
dis.reset();
data = new byte[count];
for(int i=0;i<count;i++)
{
data[i]=dis.readbyte();
}
for(int i=0;i<data.length;i++)
{
if(data[i]!=44&&data[i]!=10&&data[i]!=13)
{
if(highpostion==-1)
{
highpostion=data[i]-48;
}
else
{
lowpostion=data[i]-48;
}
}
else
{
if(data[i]==44)
{
numcount++;
if(lowpostion!=-1&&highpostion!=-1)
{
num=highpostion*10+lowpostion;
}
else if(highpostion!=-1&&lowpostion==-1)
{
num=highpostion;
}
highpostion=-1;
lowpostion=-1;
system.out.println("/t"+i+"/t/t"+num+"/t/t"+numcount);
}
}
}
}catch(exception e)
{
e.printstacktrace();
}
finally
{
in = null;
}
}
在j2me中读取txt文件数据
原创
©著作权归作者所有:来自51CTO博客作者曹观沧海的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Python计算多个Excel文件数据的平均值
本文介绍基于Python语言,对大量不同的Excel文件加以跨文件、逐单元格平均值计算的方法~
Python Excel 平均值 跨文件平均值 平均数 -
j2me读取中文的配置文件
还可以参考这篇文章:http://gundumw100.iteye.com/blog/734885impo
java 读取配置文件 System -
J2ME 安装
[code="java"]J2ME 安装 心得2009-09-05 9:13jdk1.5.4.exe——Java运行环境安装文件eclipsesdk_win32.zip——
开发工具 java runtime eclipse Java -
j2me and android
停状态)当手机来电接电话的时候,会调用该接口。用户可以调用该
UI Android sed -
j2me入门
在这里我基本上讲解的是客户端.而客户端用的是j2me来设计.所以这篇文章将详细的介绍有关j2me的体系以及入门.(内容有些部分将Co
J2SE SUN 客户端 main方法 System -
J2ME读取UTF-8编码文件方法
1 = (byte) 0x0d; //utf-8编码中换行字节1 private final static byte ent
j2me string byte command 字符串数组 -
J2ME RMS封装
tring name; String fileUrl; int picSize;
System i++ 封装 -
其他J2ME知识
1,混淆时堆栈溢出的解决办法
j2me string motorola 手机 中国移动 -
Python 抖音直播间 自动评论
目录前言效果预览评论框列表添加评论从下往上显示支持昵称颜色给出NSAttributedString点赞动画 前言最近做了直播功能,其实难度不是说很大,主要是方案和SDK的选择、整个直播流程的异常处理和优化,还有第三方SDK的填坑。不过本文只是记录下评论框和点赞效果的实现,其他的是用第三方SDK,觉得没什么好分享的,只是了解了直播流程和开发中会遇到的问题。 但看到效果还是蛮激动和蛮有成就感的,这个
Python 抖音直播间 自动评论 粒子动画 CAEmitterLayer CAEmitterCell 直播