测试 用electron + springboot 构建桌面应用
whyczh
2022-03-17 e0461d0574adba934ec2893b877dc60132bceced
更新
2个文件已修改
52 ■■■■■ 已修改文件
src/main/java/testElectronJ/FboDataInf.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/testElectronJ/TestController.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/testElectronJ/FboDataInf.java
@@ -73,6 +73,49 @@
    }
    
    
    public void readFboFileStream(FileInputStream fis)
    {
        try {
            byte[] buf = new byte[256];
            if(fis.read(buf, 0, buf.length) == 256)
            {
                this.fboDataStart.setDataInf(buf,this.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[this.fboDataStart.BattGroup*14 + 40];
                        if(fis.read(databuf) == databuf.length)
                        {
                            FboData m_FboData = new FboData(this.fboDataStart.BattGroup);
                            m_FboData.m_DataType = mType;
                            m_FboData.setData(databuf);
                            fboData.add(m_FboData);
                        }
                    }
                    if(tag == 1)
                        break;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(null != fis)
            {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    public static void main(String[] args) {
        FboDataInf fbo = new FboDataInf();
        //fbo.readFboFile("D:/test/F2022-03-09 11.26.12.FBX");
src/main/java/testElectronJ/TestController.java
@@ -3,6 +3,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.FileInputStream;
import java.io.UnsupportedEncodingException;
@RestController
@@ -24,5 +25,13 @@
        return new Response().set(1,fboDataInf,filePath);
    }
    @PostMapping("/readFboFileStream")
    public Response readFboFileStream(@RequestParam FileInputStream fis) {
        FboDataInf fboDataInf = new FboDataInf();
        //String filePath1 = java.net.URLDecoder.decode(filePath,"utf-8");
        fboDataInf.readFboFileStream(fis);
        return new Response().set(1,fboDataInf);
    }
}