title: Simple file delete code is not working in Java
body: <p>Here is my code of deleting the pdf file </p>
  
  <pre><code>try {
      File file = new File(docObjectId + ".pdf");
      file.setWritable(true);
      System.out.println(file.length());
      if (file.delete()) {
          System.out.println(file.getName() + " is deleted!");
      } else {
          System.out.println("Delete operation is failed.");
      }
  } catch (Exception e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>It goes to the else part of the code.</p>
  
  <p>PDF file is in project root folder and I am able to delete it manually. Scratching my head now.</p>
  
  <p>Here is complete method. It might be due to some other reason</p>
  
  <pre><code>public Response getContractDocument(@PathParam("docid") String docObjectId) throws Exception {
      DocumentumService documentumService = new DocumentumService(documentumConfigUtil);
      DocumentumDocumentBean docDocumentBean = documentumService.getContractDocContent(docObjectId, true);
  
      FileInputStream fileInputStream;
      fileInputStream = new FileInputStream(docDocumentBean.getDocFile());
      compressPdf(fileInputStream,docObjectId + ".pdf");
  
      fileInputStream = new FileInputStream(docObjectId + ".pdf");
  
  
      ResponseBuilder responseBuilder = Response.ok((Object) fileInputStream);
      try {
          File file = new File(docObjectId + ".pdf");
          System.out.println(file.getAbsolutePath());
          file.setWritable(true);
          System.out.println(file.length());
  
          File d = new File(file.getAbsolutePath());
          if (d.delete()) {
              System.out.println(file.getName() + " is deleted!");
          } else {
              System.out.println("Delete operation is failed.");
          }
      } catch(Exception e) {
          e.printStackTrace();
      }
      return responseBuilder.build();
  }
  </code></pre>