aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/pom.xml4
-rw-r--r--utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java13
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/coder/StandardCoderTest.java9
3 files changed, 9 insertions, 17 deletions
diff --git a/utils/pom.xml b/utils/pom.xml
index 75173a2a..03cc766a 100644
--- a/utils/pom.xml
+++ b/utils/pom.xml
@@ -122,5 +122,9 @@
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
</dependencies>
</project>
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);
}
}
diff --git a/utils/src/test/java/org/onap/policy/common/utils/coder/StandardCoderTest.java b/utils/src/test/java/org/onap/policy/common/utils/coder/StandardCoderTest.java
index a468f0b4..33c7331e 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/coder/StandardCoderTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/coder/StandardCoderTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,6 +52,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import lombok.ToString;
import org.junit.Before;
import org.junit.Test;
@@ -358,13 +359,9 @@ public class StandardCoderTest {
}
+ @ToString
private static class MyObject {
private String abc;
-
- @Override
- public String toString() {
- return "MyObject [abc=" + abc + "]";
- }
}
public static class MyMap {