summaryrefslogtreecommitdiffstats
path: root/sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2017-09-26 13:16:05 +0300
committerTal Gitelman <tg851x@intl.att.com>2017-09-26 13:16:05 +0300
commitd4f3968c952b9717c93e37615673cf36c4c00f9e (patch)
treeb5808941baa646c61f5387d28c616b29c856106b /sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java
parentce04f503bd97600c3f6774599ffbb5ef32ac90d8 (diff)
Sonar issues fix review
Change-Id: I84eddf5e65403fb617d9d2c32b8818b2b00c381f Issue-ID:SDC-352 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java')
-rw-r--r--sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java60
1 files changed, 28 insertions, 32 deletions
diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java
index c7345f2..434952b 100644
--- a/sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java
+++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java
@@ -23,40 +23,36 @@ package org.openecomp.test;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
-
import org.apache.commons.codec.binary.Base64;
public class Decoder {
- public static String encode(byte[] byteArrayToEncode) {
-
- byte[] bytesEncoded = Base64.encodeBase64(byteArrayToEncode);
- String strEncoded = new String(bytesEncoded);
- return strEncoded;
- }
-
- public static String decode(String strEncoded) throws IOException {
-
- byte[] byteDecoded = Base64.decodeBase64(strEncoded);
- String decoded = new String(byteDecoded);
-
- return decoded;
-
- }
-
- public static String readFileToString(String file) throws IOException {
-
- BufferedReader reader = new BufferedReader(new FileReader(file));
- String line = null;
- StringBuilder stringBuilder = new StringBuilder();
- String ls = System.getProperty("line.separator");
-
- while ((line = reader.readLine()) != null) {
- stringBuilder.append(line);
- stringBuilder.append(ls);
- }
- reader.close();
- return stringBuilder.toString();
- }
-
+ public static String encode(byte[] byteArrayToEncode) {
+ return new String(Base64.encodeBase64(byteArrayToEncode));
+ }
+
+ public static String decode(String strEncoded) {
+ return new String(Base64.decodeBase64(strEncoded));
+ }
+
+ public static String readFileToString(String file) throws IOException {
+
+ try (FileReader fileReader = new FileReader(file);
+ BufferedReader reader = new BufferedReader(fileReader)) {
+ String line;
+ StringBuilder stringBuilder = new StringBuilder();
+ String ls = System.getProperty("line.separator");
+
+ while ((line = reader.readLine()) != null) {
+ stringBuilder.append(line);
+ stringBuilder.append(ls);
+ }
+
+ reader.close();
+ fileReader.close();
+ return stringBuilder.toString();
+ } catch (IOException e) {
+ throw new IOException(e);
+ }
+ }
}