在java中的程序运行之间存储数据的最佳方法? [英] Best way to store data between program runs in java?

查看:141
本文介绍了在java中的程序运行之间存储数据的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中的程序运行之间存储数据的最佳方法是什么?我已经知道你可以使用文本文件并以这种方式存储信息,但我想知道是否有更好的方法来存储程序运行之间程序生成的信息。

What is the best way to store data between program runs in Java? I already know that you can use a text file and store the information that way, but I was wondering if there is a better way to store the information that is generated by the program between runs of the program.

此外,有什么办法可以保证信息的安全吗?具体来说,我想让最终用户无法访问它。

Also, is there any way to do it so as to keep the information secure? Specifically, I want to keep the end user from being able to access it.

推荐答案


我是想知道是否有任何方式
其他方法在程序运行
之间放置由程序生成的
信息?

I was wondering if there was any way other placing the information that is genereated by the program between runs of the program?

只需使用 ObjectOutputStream 将其序列化为一个文件,并使用 ObjectInputStream 将其取回。

Simply use an ObjectOutputStream to serialize it into a file and an ObjectInputStream to get it back.


还有什么方法可以这样做,因为
可以保证信息安全吗?从
最终用户能够访问它?

Also is there any way to do it so as to keep the information secure? from the end user being able to access it?

如果代码在最终用户的系统上运行那么不,那里没有办法阻止他们获取数据 - 它甚至不值得花时间尝试以某种方式对其进行编码,因为它很容易连接调试器并在程序运行时检查程序的状态。作为二进制格式,Java序列化将阻止非技术用户破译它,这几乎是你所希望的最好的。

If the code runs on the end user's system then no, there is no way to prevent them from getting the data - it's not even worth your time trying to encode it somehow, since it's easy to attach a debugger and inspect the program's state while it's running. As a binary format, Java serialization will prevent non-technical users from deciphering it, and that's pretty much the best you can hope for.

这篇关于在java中的程序运行之间存储数据的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆