size()==0 and size() > 0 -> isEmpty() for efficiency

A fix brought to you by IntelliJ :)
Inspection: Use correct size array with toArray()
Inspection: Inner class may be static
Inspection: "".equals(str) to str != null && str.isEmpty()

Some redundancy remains where str == null || "".equals(str) was original
expression.
Inspection: Manual add to array -> Collections.addAll()
Inspection: Unnecessary temp object in conversion to string
Inspection: Str concat as arg to StringBuilder/Buffer.append()
Inspection: StringBuffer -> StringBuilder