whyclxw
2024-12-23 81a9d00e46d37f950771d42aadb1f91c8069ba20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.whyc.service;
 
import com.whyc.fbo.FboData;
import com.whyc.fbo.FboDataInf;
import org.springframework.stereotype.Service;
 
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
 
@Service
public class FboDataInfService {
    public FboDataInf readFboFile(String filePath)
    {
        FboDataInf fboDataInf=new FboDataInf();
        FileInputStream fis = null;
        try {
            File f = new File(filePath);
            if(!f.exists()) {
                //System.out.println("文件不存在..........");
            }
            fis = new FileInputStream(f);
            byte[] buf = new byte[256];
            if(fis.read(buf, 0, buf.length) == 256)
            {
                fboDataInf.fboDataStart.setDataInf(buf,fboDataInf.fboDataStop);
                FboData.DataType mType = new FboData().new DataType();
 
                while(true)
                {
                    int tag = mType.checkDataHead(fis);
                    if((0xFD == tag) || (0xFC == tag) || (0xFB == tag))
                    {
                        byte[] databuf = new byte[fboDataInf.fboDataStart.BattGroup*14 + 40];
                        if(fis.read(databuf) == databuf.length)
                        {
                            FboData m_FboData = new FboData(fboDataInf.fboDataStart.BattGroup);
                            m_FboData.m_DataType = mType.clone();
                            m_FboData.setData(databuf);
                            fboDataInf.getFboData().add(m_FboData);
                        }
                    }
                    if(tag == 1)
                        break;
                }
            }
 
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(null != fis)
            {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return  fboDataInf;
    }
 
 
    public static void main(String[] args) {
        FboDataInfService service = new FboDataInfService();
        //service.readFboFile("D:/test/F2022-03-09 11.26.12.FBX");
        //service.readFboFile("D:/test/F2022-03-09 16.22.37.FBX");
        //service.readFboFile("D:/test/F2022-03-10 11.12.30.FBX");
        service.readFboFile("C:\\Users\\Administrator\\Desktop\\F2022-05-09 10.45.12.FBX");
    }
}