简体   繁体   English

Java:将InputStream转换为OutputStream

[英]Java: Convert an InputStream to an OutputStream

I'm attempting to extend java.util.Properties so that when the properties file is written the entire file is encrypted. 我正在尝试扩展java.util.Properties,以便在写入属性文件时对整个文件进行加密。 This I have a POC working, and seems easy enough to do. 我有一个POC,似乎很容易做到。

In addition, I'm trying to make it so that when a non-encrypted properties file is read, it is immediately written back out as an encrypted properties file. 另外,我正在尝试使之成为一个读取非加密的属性文件时,将其立即写回为加密的属性文件。 This I'm having a more difficult time with. 这让我遇到了更多困难。

Since the "load" method of the java.util.Properties only passes in an InputStream, I need some mechanism to turn the InputStream into an OutputStream to send the encrypted content to. 由于java.util.Properties的“ load”方法仅传入InputStream,因此我需要某种机制将InputStream转换为OutputStream以便将加密的内容发送到该方法。

Is this possible to do, or is there no way to get an Outputstream from an InputStream? 这是可能做到的,还是没有办法从InputStream获取Outputstream?

我建议将InputStream中的值保存到字符串中,然后使用java.util.Properties store方法将数据写入加密的属性文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM