package io.pivotal.labs.cfenv;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class ResourceUtils {

    public static String loadResource(String name) throws IOException {
        try (InputStream stream = openResource(name)) {
            Scanner scanner = new Scanner(stream, StandardCharsets.UTF_8.name()).useDelimiter("\\z");
            String content = scanner.next();
            IOException exception = scanner.ioException();
            if (exception != null) throw exception;
            return content;
        }
    }

    public static InputStream openResource(String name) throws FileNotFoundException {
        InputStream stream = ResourceUtils.class.getResourceAsStream(name);
        if (stream == null) throw new FileNotFoundException(name);
        return stream;
    }

}

@@ -135,60 +135,26 @@
 ava.
-n
 io.
-charset.StandardCharsets;%0Aimport java.util.Scann
+InputStreamRead
 er;%0A
@@ -329,279 +329,338 @@
    S
-canner scanner = new Scanner(stream, StandardCharsets.UTF_8.name()).useDelimiter(%22%5C%5Cz%22);%0A            String content = scanner.next();%0A            IOException exception = scanner.ioException();%0A            if (exception != null) throw exception;%0A            return content
+tringBuilder buffer = new StringBuilder();%0A            InputStreamReader reader = new InputStreamReader(stream);%0A            while (true) %7B%0A                int character = reader.read();%0A                if (character == -1) break;%0A                buffer.append((char) character);%0A            %7D%0A            return buffer.toString()
 ;%0A  

Fix resource loading to work with files bigger than a kilobyte