Synopsis: | Avoid concatenating nonliterals in a StringBuffer constructor or append() |
Language: | Java |
Severity Level: | 3 |
Category: | StringandStringBuffer |
Description: |
Avoid concatenating non literals in a StringBuffer constructor or append().public class Foo { void bar() { // Avoid this StringBuffer sb=new StringBuffer("tmp = "+System.getProperty("java.io.tmpdir")); // use instead something like this StringBuffer sb = new StringBuffer("tmp = "); sb.append(System.getProperty("java.io.tmpdir")); } } |