From 601a09fd07960d3aadcf972ba7c72dcea9976aef Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 21 May 2021 12:19:44 -0400 Subject: Enhance toString methods in factory classes The factory classes in policy-endpoints have toString() methods that return "[]" for their list contents. Updated the code to provide a list of the keys rather than just an empty list. Also replaced some toString() methods with lombok. Also replace StringBuilder with concatenation in some cases. Issue-ID: POLICY-3298 Change-Id: I64fca21a4b009f7e09fcc482b5d156753fb7e680 Signed-off-by: Jim Hahn --- .../onap/policy/common/utils/resources/TextFileUtils.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'utils/src/main') diff --git a/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java b/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java index 6039e083..7cd09fa8 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java +++ b/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java @@ -28,6 +28,7 @@ import java.io.InputStreamReader; import java.io.Reader; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import org.apache.commons.io.IOUtils; /** * The Class TextFileUtils is class that provides useful functions for handling text files. Functions to read and write @@ -36,7 +37,6 @@ import java.nio.file.Files; * @author Liam Fallon (liam.fallon@est.tech) */ public abstract class TextFileUtils { - private static final int READER_CHAR_BUFFER_SIZE_4096 = 4096; private TextFileUtils() { // This class cannot be initialized @@ -100,15 +100,6 @@ public abstract class TextFileUtils { * @throws IOException on errors reading text from the file */ public static String getReaderAsString(final Reader textReader) throws IOException { - final var builder = new StringBuilder(); - int charsRead = -1; - final var chars = new char[READER_CHAR_BUFFER_SIZE_4096]; - do { - charsRead = textReader.read(chars); - if (charsRead > 0) { - builder.append(chars, 0, charsRead); - } - } while (charsRead > 0); - return builder.toString(); + return IOUtils.toString(textReader); } } -- cgit 1.2.3-korg