aboutsummaryrefslogtreecommitdiffstats
path: root/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-05-24 20:51:53 +0000
committerGerrit Code Review <gerrit@onap.org>2021-05-24 20:51:53 +0000
commit41d130dd1bc967f8163ab2304ed4067254034151 (patch)
tree0f735b08dfff1f8004106a240d4ae1b875c7179e /utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java
parent57410a85a607f71d4094dae9d9e57dabb7b0b33a (diff)
parent601a09fd07960d3aadcf972ba7c72dcea9976aef (diff)
Merge "Enhance toString methods in factory classes"
Diffstat (limited to 'utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java')
-rw-r--r--utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java13
1 files changed, 2 insertions, 11 deletions
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);
}
}