Here my related code:
public String build() {
StringBuilder s3Key = new StringBuilder();
if (bucketName == null || fileName == null) {
throw new IllegalStateException("Bucket name and file name are required");
}
s3Key.append(bucketName);
String prefix = paths.stream().filter(Predicate.not(Strings::isNullOrEmpty)).collect(Collectors.joining("/"));
s3Key.append(prefix);
s3Key.append(fileName);
return s3Key.toString();
}
Is there any way to collect streamed string into existent s3Key
StringBuilder
?