flatbuffer突变返回true,但文件中没有变化

我在Java中使用flatbuffer突变。当我在flatbuffer文件中更改单个用户的值时,它返回true。但是之后,当我再次检查我的二进制文件时,我看不到其中的任何更改。我在做什么错不知道?

enter code here 

            for (int i = 0; i < length; i++) {

                SingleJson monsters = monsterList.monsters(i);
                monsters.mutateEmpNo(Short.parseShort(empNo));//it returns true,but in file their is not any change.
                for (int j = 0; j < 512; j++) {
                    monsters.mutateEmbedding(j,monsters.Embedding(j));
                }
                break;
            }

        }
milu_yaya 回答:flatbuffer突变返回true,但文件中没有变化

实际上我得到了一个答案,我犯了一个错误,即我更改了内存中的值,但没有将其写入文件中。因此在这里我们必须在变异后再次写入整个文件。 并写了我使用了fileOutputStream。以及在变异后获取字节的代码- monsterList.getByteBuffer()。array()

本文链接:https://www.f2er.com/2550230.html

大家都在问