读取android手机流量信息(5)
in.close();
}
catch (IOException e) {
DisplayToast(e.toString());
}
return str;
}
public void writefile(String str,String path )
{
File file;
FileOutputStream out;
try {
//创建文件
file = new File(path);
file.createNewFile();
//打开文件file的OutputStream
out = new FileOutputStream(file);
String infoToWrite = str;
//将字符串转换成byte数组写入文件
out.write(infoToWrite.getBytes());
//关闭文件file的OutputStream
out.close();
} catch (IOException e) {
//将出错信息打印到Logcat
DisplayToast(e.toString());
}
}
public void refresh()
{
readdev();//读取本次开机之后直到当前系统的总流量
data=ethdata[0]+","+ethdata[1]+","+ethdata[8]+","+ethdata[9]+","
+gprsdata[0]+","+gprsdata[1]+","+gprsdata[8]+","+gprsdata[9]+","
+wifidata[0]+","+wifidata[1]+","+wifidata[8]+","+wifidata[9];
String onstr=getinfo(ONPATH);//读取on.txt记录到onstr里
String ondata[]=onstr.split(",");//将onstr各项分离 放到ondata里
//计算增量
int [] delta=new int [12];
delta[0]=Integer.parseInt(ethdata[0])-Integer.parseInt(ondata[0]);
delta[1]=Integer.parseInt(ethdata[1])-Integer.parseInt(ondata[1]);
delta[2]=Integer.parseInt(ethdata[8])-Integer.parseInt(ondata[2]);
delta[3]=Integer.parseInt(ethdata[9])-Integer.parseInt(ondata[3]);
delta[4]=Integer.parseInt(gprsdata[0])-Integer.parseInt(ondata[4]);
delta[5]=Integer.parseInt(gprsdata[1])-Integer.parseInt(ondata[5]);
delta[6]=Integer.parseInt(gprsdata[8])-Integer.parseInt(ondata[6]);
delta[7]=Integer.parseInt(gprsdata[9])-Integer.parseInt(ondata[7]);
相关新闻>>
- 发表评论
-
- 最新评论 更多>>