[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-be / lib / openecomp-core-lib / openecomp-utilities-lib / src / main / java / org / openecomp / core / utilities / file / FileUtils.java
index 72fa9ac..664ccb6 100644 (file)
 
 package org.openecomp.core.utilities.file;
 
+import org.apache.commons.collections4.CollectionUtils;
 import org.openecomp.core.utilities.json.JsonUtil;
 import org.openecomp.core.utilities.yaml.YamlUtil;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorDescription;
+import org.slf4j.MDC;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
+import java.io.*;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Enumeration;
@@ -58,6 +58,23 @@ public class FileUtils {
     return is;
   }
 
+  /**
+   * Gets file input stream.
+   *
+   * @param urlFile the url file
+   * @return the file input stream
+   */
+  public static InputStream getFileInputStream(URL urlFile) {
+    InputStream is;
+    try {
+      assert urlFile != null;
+      is = urlFile.openStream();
+    } catch (IOException exception) {
+      throw new RuntimeException(exception);
+    }
+    return is;
+  }
+
   /**
    * Gets file input streams.
    *
@@ -134,9 +151,9 @@ public class FileUtils {
    * @return the input stream
    */
   public static InputStream loadFileToInputStream(String fileName) {
-    URL urlFile = FileUtils.class.getClassLoader().getResource(fileName);
+    URL urlFile = Thread.currentThread().getContextClassLoader().getResource(fileName);
     try {
-      Enumeration<URL> en = FileUtils.class.getClassLoader().getResources(fileName);
+      Enumeration<URL> en = Thread.currentThread().getContextClassLoader().getResources(fileName);
       while (en.hasMoreElements()) {
         urlFile = en.nextElement();
       }
@@ -248,6 +265,7 @@ public class FileUtils {
     return mapFileContent;
   }
 
+
   /**
    * The enum File extension.
    */