I have a question on writing a method signature, whether to pass an argument as a String or a StringBuffer?
The question is in the lines of the performance and also in the lines of pass by value/reference.
Here's the scenario:
I'm writing a method to parse an xml and add the XML attributes to a file, And within this file, I insert these values on particular linenumber/offset.
1. The file I get is in the form of a String 2. And in a HashMap I get the xml attributes, values 3. I call the method in a for loop while reading the xml values from the HashMap 4. So each time the method is called, the modified-file is sent as a String? or StringBuffer? 5. The size of the file will be max 32KB.
Can I pass the file as a StringBuffer Object rather than a String to the calling method. As this method is called in a loop several times, it is better to have the file as a String Buffer?