How do I load a resource and use its contents as a string in Spring

In one line try this to read test.xml:

String msg = StreamUtils.copyToString( new ClassPathResource("test.xml").getInputStream(), Charset.defaultCharset()  );

Leave a Comment