Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Get file from resources folder
- ClassLoader classLoader = getClass().getClassLoader();
- URI filepath = new URI(classLoader.getResource(path).toString());
- File file = new File(filepath);
- Scanner scanner = new Scanner(file);
- while (scanner.hasNextLine()) {
- String line = scanner.nextLine();
- result.append(line).append("\n");
- }
- scanner.close();
- } catch (IOException e) {
- e.printStackTrace();
- } catch(URISyntaxException e){
- e.printStackTrace();
- }
- return result.toString().replaceAll("\\n\\r|\\n|\\r|\\t|\\s{2,}","");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement