private static String loadResource(Class<?> testClass, String resourcePath) throws IOException {
        StringBuilder stringBuilder = new StringBuilder();
        try (InputStream inputStream = testClass.getResourceAsStream(resourcePath);
                Scanner scanner = new Scanner(inputStream, StandardCharsets.UTF_8.name())) {
            while (scanner.hasNext()) {
                stringBuilder.append(scanner.nextLine()).append('\n');
            }
        }
        return stringBuilder.toString();
    }
Load a local file (e.g. example JSON Schema) from the given resource path, relative to the package of the indicated test class.

@param testClass test class requesting a file to be loaded
@param resourcePath relative path to the target file
@return file contents
@throws IOException when the file loading failed
jsonschema-generator/src/test/java/com/github/victools/jsonschema/generator/TestUtils.java