80,348
社区成员
发帖
与我相关
我的任务
分享
private void ReadPic(){
try{
InputStream in = getResources().openRawResource(R.raw.app704);
boolean bRet = IsContainSpecialChars(in);
Toast.makeText(this, "" + bRet, Toast.LENGTH_SHORT).show();
in.close();
}
catch(Exception e){
e.printStackTrace();
}
}
// 查找"0x00,0x00,0x00,0x01"
private boolean IsContainSpecialChars(InputStream in){
try{
byte [] buffer = new byte[1001];
int nRead = 0;
int nZeroCount = 0;
int nClips = 0;
while ((nRead = in.read(buffer)) > 0){
nClips++;
for (int i=0; i<nRead; i++)
{
if (buffer[i] == 0x00)
{
nZeroCount++;
}
else
{
if (nZeroCount >= 3 && buffer[i] == 0x01)
{
Toast.makeText(this, "found postion:" + ((nClips - 1) * 1001 + i) , Toast.LENGTH_SHORT).show();
return true;
}
nZeroCount = 0;
}
}
}
}
catch(Exception e){
e.printStackTrace();
}
return false;
}