I need to add key value pairs to a properties file.the values are separated by # , ; , =,-.
All are working fine except # and = everytine a \ is appended before the characters.
Please share me any suggestion for making this possible.
That is by design. Since characters such as # and = have a special meaning in properties files, they need to be escaped with a \ if you want to include a literal # or = in the properties file. That's just how Java properties files work.
If you remove the \ somehow, then class java.util.Properties might not be able to load the file properly, so I suggest you just leave the \ in there.
What exactly do you want to do? Note that the correct way to read and write a properties file is to use the load() and store() methods of class java.util.Properties. This will automatically (un)escape special characters, so you don't have to deal with those special characters yourself.
In Java source code, the \ has a special meaning. If you want to include a \ in a string literal, you'll have to write \\: