I am reading a properties file from database.
I checked java.util.Properties and there’s no method to parse from a String instance. Is there any way to do it?
I am reading a properties file from database. I checked java.util.Properties and there’s no
Share
You’re right that
java.util.Propertiesdoesn’t have a method to read from aString– but in fact it has more general methods that read from anInputStreamorReader.So you can call
loadif you have some way of presenting yourStringas either of these, i.e. a source which effectively iterates over characters one by one. This feels like it ought to exist, and indeed it does – java.io.StringReader.Putting it together, then, is quite straightforward: