↗ JetBrains 20% discount
Buy any product from JetBrains and get a 20% discount.
Spring MVC
@RequestMapping(method = RequestMethod.POST) public String handlePost(@RequestParam("user-file") MultipartFile multipartFile, Model model) throws IOException { String name = multipartFile.getOriginalFilename(); Path path = Paths.get("d:\\filesUploaded\\" + name); Path parent = path.getParent(); if (!Files.exists(parent)) { Files.createDirectory(parent); } else if (Files.exists(path)) { Files.delete(path); } BufferedWriter w = Files.newBufferedWriter(path); w.write(new String(multipartFile.getBytes())); w.flush(); model.addAttribute("msg", "File has been uploaded. name: " + name+ " content: "+new String(multipartFile.getBytes())); return "response"; }