title: The file not exist exception in Java
body: <p>I try to upload file from web, and the file are stored in the file system. </p>
  
  <pre><code>@RequestMapping(value = "/upload", method = RequestMethod.POST)
  public @ResponseBody String handleFileUpload(
          @RequestParam("name") String name,
          @RequestParam("file") MultipartFile file) {
      if (!file.isEmpty()) {
          try {
              byte[] bytes = file.getBytes();
              File file1 = new File(name + ".upload");
              BufferedOutputStream stream = new BufferedOutputStream(
                      new FileOutputStream(file1));
  
              stream.write(bytes);
              stream.close();
              return "You successfully uploaded " + name + " into " + name
                      + "-uploaded !";
          } catch (Exception e) {
              e.printStackTrace();
              return "You failed to upload " + name + " =&gt; " + e.getMessage();
          }
      } else {
          return "You failed to upload " + name
                  + " because the file was empty.";
      }
  }
  </code></pre>
  
  <p>the above code work well. But when I try to use absolute directory, it fail, the code like </p>
  
  <pre><code>@RequestMapping(value = "/upload", method = RequestMethod.POST)
  public @ResponseBody String handleFileUpload(
          @RequestParam("name") String name,
          @RequestParam("file") MultipartFile file) {
      if (!file.isEmpty()) {
          try {
              byte[] bytes = file.getBytes();
              File file1 = new File("c:/" + name + ".uploaded");
              file1.getParentFile().mkdirs();
              BufferedOutputStream stream = new BufferedOutputStream(
                      new FileOutputStream(file1));
  
              stream.write(bytes);
              stream.close();
              return "You successfully uploaded " + name + " into " + name
                      + "-uploaded !";
          } catch (Exception e) {
              e.printStackTrace();
              return "You failed to upload " + name + " =&gt; " + e.getMessage();
          }
      } else {
          return "You failed to upload " + name
                  + " because the file was empty.";
      }
  }
  </code></pre>
  
  <p>It throw file not exists exception, and I have already create dirs. Does someone know the reason? Thanks!</p>