How to convert Map to Bytes and save to internal storage

前端 未结 3 1585
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-20 17:09

How can I convert my Map> to byte[], and then write it to internal storage? I currently have:

        try {
                 


        
3条回答
  •  轮回少年
    2021-02-20 17:34

    Either serialize like faylon mentioned, or implement your own mechanism to save and load your map. By saving, you iterate over all elements and save key-value pairs. By loading, you add them back. Implementing your own mechanism has the advantage that you can still use your persisted values when your program is used with another Java version.

提交回复
热议问题