From 565333a74809d07f1a6a3424c09fa05bc5b7149c Mon Sep 17 00:00:00 2001
From: Max Wittig <max.wittig95@gmail.com>
Date: Thu, 27 Oct 2016 18:55:23 +0200
Subject: [PATCH] added method to add content from raw text url

---
 src/de/bricked/utils/FileUtils.java | 45 +++++++++++++++++++++--------
 1 file changed, 33 insertions(+), 12 deletions(-)

diff --git a/src/de/bricked/utils/FileUtils.java b/src/de/bricked/utils/FileUtils.java
index 24e14d3..4aae5ac 100644
--- a/src/de/bricked/utils/FileUtils.java
+++ b/src/de/bricked/utils/FileUtils.java
@@ -9,26 +9,33 @@ import java.io.BufferedInputStream;
 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.net.URL;
 
 public class FileUtils
 {
+
+    private static String getContentsFromInputStream(InputStream inputStream) throws Exception
+    {
+        BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
+        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(bufferedInputStream));
+        String line = "";
+        StringBuilder text = new StringBuilder();
+
+        while (line != null)
+        {
+            line = bufferedReader.readLine();
+            if (line != null)
+                text.append(line);
+        }
+        return text.toString();
+    }
+
     public static String getFileContentFromJar(String path)
     {
         try
         {
             InputStream inputStream = FileUtils.class.getResourceAsStream(path);
-            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
-            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(bufferedInputStream));
-            String line = "";
-            StringBuilder text = new StringBuilder();
-
-            while (line != null)
-            {
-                line = bufferedReader.readLine();
-                if (line != null)
-                    text.append(line);
-            }
-            return text.toString();
+            return getContentsFromInputStream(inputStream);
         }
         catch (Exception e)
         {
@@ -36,4 +43,18 @@ public class FileUtils
         }
         return null;
     }
+
+    public static String getURLContentFromJar(String urlString)
+    {
+        try
+        {
+            InputStream in = new URL(urlString).openConnection().getInputStream();
+            return getContentsFromInputStream(in);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return null;
+    }
 }
-- 
GitLab