This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
i have this proerties file which has two keys (classpath,server). After changing one of the key and store it in a file , i noticed the comments are misssing. How to retain the comments afeter modifying the value.
File.properties # Server Configuration File
# CLASSPATH - This is the classpath used by the Server classpath=AdventNetLogging.jar:
# Location of the jserver.properties file SERVER=myserver
Thanks [ July 11, 2007: Message edited by: Sree Va ]
We believe that every being is divine, is God. Every soul is a sun covered over with clouds of ignorance; the difference between soul and soul is owing to the difference in density of these layers of clouds. - Swami Vivekananda
iyappan: The java.util.Properties class was not designed to keep the format of the properties file exactly the same. So if you load and save your properties file by using the methods in class Properties, the comments and formatting will not be preserved. If this is really important, then you will have to read and write the file yourself (with BufferedReader and FileWriter) and parse and format the properties yourself.
Sree: You are hijacking someone else's topic; please start your own topic next time... To answer your question: So you expected that the Properties class would automatically replace ${...} somehow. It doesn't; that is not functionality of the Properties class. You probably saw this when you were using Ant. Ant is doing this for you; not the java.util.Properties class. So if you need this kind of functionality, you will need to program it yourself: search for ${...} expressions, and replace them by whatever you want.