title: How to read a Multipart file as a string in Spring?
body: <p>I want to post a text file from my desktop using Advanced Rest Client.
  This is my controller:</p>
  
  <pre><code>@RequestMapping(value = "/vsp/debug/compareConfig/{deviceIp:.*}", method = RequestMethod.POST, consumes = { "multipart/form-data" }, produces = { "application/json" })
  
  public ResponseEntity&lt;SuccessResult&gt; compareCLIs(HttpServletRequest request, @RequestParam("file") MultipartFile file, @PathVariable("deviceIp") String device) 
  {
  log.info(file.getOriginalFilename());
  byte[] bytearr = file.getBytes();
  log.info("byte length: ", bytearr.length);
  log.info("Size : ", file.getSize());
  
  }
  </code></pre>
  
  <p>This does not return any value for byte length or file size. I want to read the file values to a StringBuffer. Can someone provide pointers regarding this? I am not sure if I need to save this file before parsing it to a string. If so how do I save the file in the workspace?</p>