How to concatenate strings using Guava?
guava, java
Solution
You don't need the loop, you can do the following with Guava:
// trim the elements:
List<String> trimmed = Lists.transform(list, new Function<String, String>() {
@Override
public String apply(String in) {
return in.trim();
}
});
// join them:
String joined = Joiner.on("").join(trimmed);
Problem
I wrote some code to concatenate Strings: ``` String inputFile = ""; for (String inputLine : list) { inputFile +=inputLine.trim()); } ``` But I can't use `+` to concatenate, so I decide to go with Guava. So I need to use Joiner. ``` inputFile =joiner.join(inputLine.trim()); ``` But it's giving me an error. I need help to fix this. Many Thanks.