我需要将文件流写入数据库。文件内容必须只能通过
读取程序。手动打开文件不应显示可读内容。我决定使用
ObjectOutput流,因为它是java中的二进制写入机制。但我可以看到字符串
打开文件时的内容。
写入流
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(baos);
os.writeObject("HIIIIIIIIIIIIIIIIIIIIII HOW ARE YOU");
创建的内容看起来像
’ t #HIIIIIIIIIIIIIIIIIIIIII HOW ARE YOU
如何获得完整的二进制流输出?
最佳答案
The file content must be readable only through the program. Manual open file should not display the readable content.
所以你需要一些安全保障。
I decided to use ObjectOutput stream as it is the binary writing mechanism in java.
这是(a)不合逻辑的推论,以及(b)默默无闻的安全性:即它根本不安全。
您应该使用加密。
关于java - 读取、写入不可读的文件流以保存在数据库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25027186/