Example #1
0
 /**
  * Returns a File object for the specified file saved on the server's filesystem, or null if the
  * file was not included in the upload.
  *
  * @param name the html page's file parameter name.
  * @return a File object for the named file.
  */
 public File getFile(String name) {
   try {
     UploadedFile file = (UploadedFile) files.get(name);
     return file.getFile(); // may be null
   } catch (Exception e) {
     return null;
   }
 }
Example #2
0
 /**
  * Returns the filesystem name of the specified file, or null if the file was not included in the
  * upload. A filesystem name is the name specified by the user. It is also the name under which
  * the file is actually saved.
  *
  * @param name the html page's file parameter name.
  * @return the filesystem name of the file.
  */
 public String getFilesystemName(String name) {
   try {
     UploadedFile file = files.get(name);
     return file.getFilesystemName(); // may be null
   } catch (Exception e) {
     return null;
   }
 }
Example #3
0
 /**
  * Returns the original filesystem name of the specified file (before any renaming policy was
  * applied), or null if the file was not included in the upload. A filesystem name is the name
  * specified by the user.
  *
  * @param name the html page's file parameter name.
  * @return the original file name of the file.
  */
 public String getOriginalFileName(String name) {
   try {
     UploadedFile file = (UploadedFile) files.get(name);
     return file.getOriginalFileName(); // may be null
   } catch (Exception e) {
     return null;
   }
 }
  public static void main(String[] args) {
    String path = "C:\\Users\\NovDec2015.pdf";
    UploadedFile upF = new UploadedFile(path, "uploads");

    System.out.println(upF.getFileName());
    System.out.println(upF.getParentPath());
    System.out.println(upF.getFilePath());
    System.out.println(upF.getRelativeFilePath());
    System.out.println(upF.getWebFilePath());
    System.out.println(upF.getFileSize());
    System.out.println(upF.getFileExtension());
    System.out.println(upF.genRecord());
  }