package com.whyc.bts;
|
|
import java.io.FileInputStream;
|
import java.io.IOException;
|
|
public class BTS_DataType {
|
public static final int BYTE_LEN = 4;
|
|
public int typeTag0;
|
public int typeTag1;
|
public int typeTag2;
|
public int typeTag3;
|
|
public int checkDataHead(FileInputStream fis)
|
{
|
boolean file_end = false;
|
byte type_tag = 0;
|
byte[] tag = new byte[1];
|
try {
|
while(true)
|
{
|
type_tag = 0;
|
int n = 0;
|
for(n=0; n<4; n++)
|
{
|
if(1 != fis.read(tag, 0, 1))
|
{
|
file_end = true;
|
break;
|
}
|
if((0xFD != (tag[0]&0xFF)) && (0xFC != (tag[0]&0xFF)) && (0xFB != (tag[0]&0xFF)))
|
{
|
break;
|
}
|
}
|
|
if(n >= 4)
|
{
|
type_tag = tag[0];
|
break;
|
}
|
if(true == file_end)
|
{
|
type_tag = 1;
|
break;
|
}
|
}
|
} catch (IOException e) {
|
// TODO Auto-generated catch block
|
//e.printStackTrace();
|
}
|
setType(type_tag&0xFF);
|
|
return (typeTag0);
|
}
|
|
public byte[] getDataTypeByte() {
|
byte[] data = new byte[BYTE_LEN];
|
data[0] = BTS_ComBase.changeIntToByte(typeTag0);
|
data[1] = BTS_ComBase.changeIntToByte(typeTag1);
|
data[2] = BTS_ComBase.changeIntToByte(typeTag2);
|
data[3] = BTS_ComBase.changeIntToByte(typeTag3);
|
return data;
|
}
|
|
|
public void setType(int type)
|
{
|
typeTag0 = type;
|
typeTag1 = type;
|
typeTag2 = type;
|
typeTag3 = type;
|
}
|
}
|