private String readResourceAsString(Resource resource) throws IOException {
  StringBuilder contents=new StringBuilder();
  Reader reader=new InputStreamReader(resource.asStream(),"UTF-8");
  try {
    char buffer[]=new char[8192];
    int length;
    while ((length=reader.read(buffer)) != -1) {
      contents.append(buffer,0,length);
    }
  }
  finally {
    reader.close();
  }
  return contents.toString();
}

private String readResourceAsString ( Resource resource ) throws IOException { StringBuilder contents = new StringBuilder ( ) ; Reader reader = new InputStreamReader ( resource . asStream ( ) , "UTF-8" ) ; try { char buffer [ ] = new char [ 8192 ] ; int length ; while ( ( length = reader . read ( buffer ) ) != - 1 ) { contents . append ( buffer , 0 , length ) ; } } finally { reader . close ( ) ; } return contents . toString ( ) ; }
reads the entire contents of the given resource as a string . the resource is assumed to be encoded in utf - 8 .
