简体   繁体   English

如何从Java中的InputStream获取Ini文件的值?

[英]How to get value of Ini file from InputStream in Java?

I've developed a Web Service in Java, and my client will upload an .ini file to the service using the API which definition is something like我已经用 Java 开发了一个 Web 服务,我的客户端将使用 API 将一个.ini文件上传到该服务,其定义类似于

public Response PostStreamInfo(@Context HttpServletRequest request,
        @PathParam("UniqueId") String uniqueId, InputStream inputStream) 
        {
            /* my code here */
        }

Now I want to convert the inputStream back into .ini format, and retreive some value.现在我想将 inputStream 转换回 .ini 格式,并检索一些值。 However, all methods I found to get .ini content is read from real file , none of them talk about how to transfer from inputstream .但是,我发现获取 .ini 内容的所有方法都是从真实文件中读取的,没有一个讨论如何从inputstream传输。

Is my goal possible?我的目标可能吗? Because I don't want to Store the .ini file, Read it, and Delete it only for 1 value I need, I think that's a waste of time.因为我不想存储.ini 文件,读取它,然后删除它只为我需要的1 个值,我认为这是浪费时间。 Or should I just use Json format instead of InputStream to transfer the content?或者我应该只使用 Json 格式而不是 InputStream 来传输内容? Thanks!谢谢!

Are you dealing with actual INI files or Java property files?您是在处理实际的 INI 文件还是 Java 属性文件?

It looks like there's an Apache class that you could use via an InputStreamReader and the read method for INI files.看起来有一个Apache 类,您可以通过InputStreamReader和 INI 文件的read方法使用它。

If you're just dealing with Java property files, there are read methods that take InputStreams and also Readers.如果您只是处理 Java 属性文件,则有一些读取方法可以使用 InputStreams 和 Readers。

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

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