try with resorces 01/57801/1
authorArindam Mondal <arind.mondal@samsung.com>
Fri, 27 Jul 2018 08:37:50 +0000 (17:37 +0900)
committerONAP <arind.mondal@samsung.com>
Fri, 27 Jul 2018 08:40:54 +0000 (17:40 +0900)
Issue-ID: MSB-224
Change-Id: I2a44c88579f323150294c814c64f50d60219ee16
Signed-off-by: ONAP <arind.mondal@samsung.com>
apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/util/FileUtil.java

index 2b6468b..234bf51 100644 (file)
@@ -25,7 +25,7 @@ public final class FileUtil {
     /**
      * Read all the files under a folder
      */
-    public static File[] readFileFolder(String filepath) throws FileNotFoundException, IOException {
+    public static File[] readFileFolder(String filepath) throws  IOException {
         File file = new File(filepath);
         if (file.isDirectory()) {
             File[] filelist = file.listFiles();
@@ -36,28 +36,15 @@ public final class FileUtil {
     }
 
     public static String readFile(String Path) throws IOException {
-        BufferedReader reader = null;
-        StringBuffer fileContent = new StringBuffer();
-        try {
-            FileInputStream fileInputStream = new FileInputStream(Path);
-            InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
-            reader = new BufferedReader(inputStreamReader);
+       StringBuilder fileContent = new StringBuilder();
+        try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(Path),"UTF-8"));) {
             String tempString = null;
             while ((tempString = reader.readLine()) != null) {
                 fileContent.append(tempString);
             }
-            reader.close();
         } catch (IOException e) {
             throw e;
-        } finally {
-            if (reader != null) {
-                try {
-                    reader.close();
-                } catch (IOException e) {
-                    throw e;
-                }
-            }
-        }
+        } 
         return fileContent.toString();
     }