Skip to content
Snippets Groups Projects
Commit 565333a7 authored by Max Wittig's avatar Max Wittig
Browse files

added method to add content from raw text url

parent 95d61bf1
Branches
Tags
No related merge requests found
......@@ -9,14 +9,13 @@ import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
public class FileUtils
{
public static String getFileContentFromJar(String path)
{
try
private static String getContentsFromInputStream(InputStream inputStream) throws Exception
{
InputStream inputStream = FileUtils.class.getResourceAsStream(path);
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(bufferedInputStream));
String line = "";
......@@ -30,10 +29,32 @@ public class FileUtils
}
return text.toString();
}
public static String getFileContentFromJar(String path)
{
try
{
InputStream inputStream = FileUtils.class.getResourceAsStream(path);
return getContentsFromInputStream(inputStream);
}
catch (Exception e)
{
Logger.log(LogLevel.ERROR, Logger.exceptionToString(e));
}
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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment