title: How to save file with its original name in Struts2 while uploading a file
body: <p>I need to save uploaded file with its original name and type instead of temporary file name in separate folder.</p>
  
  <p>By using below code i can get file name and type but how can i change temporary name with its original name.</p>
  
  <pre><code> private File file1;
   private String file1ContentType;
   private String file1FileName;
  
  public File getFile1() {
   return file1;
  }
  public void setFile1(File file1) {
   this.file1 = file1;
  }
  public String getFile1ContentType() {
   return file1ContentType;
  }
  public void setFile1ContentType(String file1ContentType) {
   this.file1ContentType = file1ContentType;
  }
  public String getFile1FileName() {
   return file1FileName;
  }
  public void setFile1FileName(String file1FileName) {
   this.file1FileName = file1FileName;
  }
  
  public String upld() {      
      File dest = new File("/home/desktop/images/");
      try {
  
          System.out.println("file1FileName........"+file1FileName);
          System.out.println("file1ContentType........"+file1ContentType);
          System.out.println("file1........"+file1);
  
         FileUtils.copyFileToDirectory(file1, dest);      
         } catch (Exception e) {
  
          e.printStackTrace();
         }
         return "success";
  
      }
  </code></pre>
  
  <p>By this code its possible to save video with its temporary file name but i want to save file with its original name and type....</p>
  
  <p>or else is it possible to rename temporary file with its original name before saving in to the folder</p>