I saw the java code in my project which constructs a file name from various parameters.The java code is like this
String file = null;
String fileDirSeperator = System.getProperty("file.separator");
String pwd = System.getProperty("user.dir");
file = pwd + fileDirSeperator + "properties" + fileDirSeperator + folder_name + file_name;
I want to know if I should you StringBuffer
instead of String
. I know that appending anything to String will create new object so I think I should you StringBuffer
.
May I know your suggestion?
Also,
file = pwd + fileDirSeperator + "properties" + fileDirSeperator + folder_name + file_name;
in the above file name construction, will 6 objects be created(one for each variable)?