code: public static String readToString(Resource resource, Charset charset) throws IOException {
          if (simulationMode) {
              if (resource instanceof ClassPathResource) {
                  return ((ClassPathResource) resource).getPath();
              } else if (resource instanceof FileSystemResource) {
                  return ((FileSystemResource) resource).getPath();
              } else {
                  return resource.getFilename();
              }
          }
  
          if (log.isDebugEnabled()) {
              log.debug(String.format("Reading file resource: '%s' (encoding is '%s')", resource.getFilename(), charset.displayName()));
          }
          return readToString(resource.getInputStream(), charset);
      }
docs: Read file resource to string value.
  @param resource
  @param charset
  @return
  @throws IOException