@Test @Ignore() public void readJsonConfigAsString() throws Exception { JsonConfigReader reader = new JsonConfigReader(); String actual = reader.readAsString("config.json", Charsets.UTF_8); String expect = "{\n" + " \"port\": 9000,\n" + " \"subReactorCount\": 3,\n" + " \"router\": [\n" + " {\n" + " \"servlet-name\": \"index\",\n" + " \"path\": \"/\",\n" + " \"servlet-class\": \"xxx.xxxx.xxxxx.IndexServlet\",\n" + " \"load-on-startup\": 0\n" + " },\n" + " {\n" + " \"servlet-name\": \"reg\",\n" + " \"path\": \"/reg\",\n" + " \"servlet-class\": \"xxx.xxxx.xxxxx.RegServlet\"\n" + " }\n" + " ]\n" + "}"; assertEquals(expect,actual); }
String readAsString(String path, Charset encoding) throws Exception { URI uri = ClassLoader.getSystemResource(path).toURI(); byte[] encoded = Files.readAllBytes(Paths.get(uri)); return new String(encoded, encoding); }
JsonConfigReader { String readAsString(String path, Charset encoding) throws Exception { URI uri = ClassLoader.getSystemResource(path).toURI(); byte[] encoded = Files.readAllBytes(Paths.get(uri)); return new String(encoded, encoding); } }
JsonConfigReader { String readAsString(String path, Charset encoding) throws Exception { URI uri = ClassLoader.getSystemResource(path).toURI(); byte[] encoded = Files.readAllBytes(Paths.get(uri)); return new String(encoded, encoding); }  }
JsonConfigReader { String readAsString(String path, Charset encoding) throws Exception { URI uri = ClassLoader.getSystemResource(path).toURI(); byte[] encoded = Files.readAllBytes(Paths.get(uri)); return new String(encoded, encoding); }   }
JsonConfigReader { String readAsString(String path, Charset encoding) throws Exception { URI uri = ClassLoader.getSystemResource(path).toURI(); byte[] encoded = Files.readAllBytes(Paths.get(uri)); return new String(encoded, encoding); }    }