GeneralUtils { public static String loadResource(Class<?> cls, String path) throws CodeException { try (InputStream stream = cls.getResourceAsStream(path)) { if (stream == null) { throw new CodeExecuteException(resourceLoadError(path, "not found")); } return IOUtils.toString(stream, "UTF-8"); } catch (IOException e) { throw new CodeExecuteException(resourceLoadError(path, e.toString())); } } private  GeneralUtils(); static long toPositiveLong(CharSequence seq, int pos, int length); static Decimal nodeToDecimal(JsonNode node); static BigDecimal nodeToBigDecimal(JsonNode node); static JsonNode executeTemplate(Context ctx, Instruction inst, JsonNode node, boolean privateContext); static JsonNode executeTemplate(Context ctx, Instruction inst, JsonNode node, boolean privateContext,
        ObjectNode argvar); static String loadResource(Class<?> cls, String path); static List<Path> listResources(Class<?> cls, String pattern); static V getOrDefault(Map<K, V> map, K key, V defaultValue); static String localizeOrDefault(JsonNode localizedStrings, String key, String defaultValue); static boolean isJsonStart(String raw); static JsonNode getFirstMatchingNode(JsonNode parent, String... keys); static String jsonPretty(JsonNode node); static Object[] splitVariable(String name); static String urlEncode(String val); static boolean isTruthy(JsonNode node); static String ifString(JsonNode node, String defaultString); static double ifDouble(JsonNode node, double defaultValue); static String eatNull(JsonNode node);  }
@Test public void testLoadResourceTest() { try { GeneralUtils.loadResource(getClass(), "this/resource/is/missing.txt"); Assert.fail("GeneralUtils.loadResource() should throw on missing resource"); } catch (CodeException e) { } }