Move things around

This commit is contained in:
2018-10-13 19:15:07 +03:00
parent 9c38800214
commit fa0dc0bd2c
6 changed files with 44 additions and 6 deletions

View File

@@ -0,0 +1,26 @@
package util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.stream.Collectors;
public class FileUtil {
public static String readFileFromClasspath(String pathOnClasspath) {
try (InputStream is = FileUtil.class.getClassLoader().getResourceAsStream(pathOnClasspath)) {
if (is == null) {
throw new IllegalStateException("can't load file: " + pathOnClasspath);
}
BufferedReader buffer = new BufferedReader(new InputStreamReader(is));
return buffer.lines().collect(Collectors.joining("\n"));
} catch (IOException e) {
throw new RuntimeException();
}
}
}