2

さて、ByteArrayOutputStream を使用してダンプされたオブジェクトを作成しています。そして、それらをドキュメントの属性として MongoDB に書き込みます。読み返したら、途中で toString を使用せずにバイト配列またはバイナリに変換するにはどうすればよいですか?

これは私が今行っている方法であり、安全だとは思いません。

BasicBSONObject temp = (BasicBSONObject) models.get("0");
model = null;
    if (temp != null) {
        // TODO fix this serialization!
        try {
            ObjectInputStream ois = new ObjectInputStream(
                    new ByteArrayInputStream(temp.toString().getBytes()));

        } catch (IOException e) {
            L.error("unable to read model from string!");
            L.error(e.getStackTrace().toString());
        }
    }
4

0 に答える 0