1 6 7 package com.quikj.application.communicator.applications.webtalk.controller; 8 9 import javax.servlet.http.*; 10 import org.apache.struts.action.*; 11 import org.apache.struts.upload.FormFile; 12 import java.io.*; 13 17 public class UploadFileForm extends ActionForm{ 18 19 20 private FormFile userFile; 21 22 23 public UploadFileForm() { 24 } 25 26 public void reset() 27 { 28 userFile = null; 29 } 30 31 public ActionErrors validate(ActionMapping mapping, 32 HttpServletRequest request) 33 { 34 ActionErrors errors = new ActionErrors(); 35 36 if (userFile == null) 37 { 38 errors.add("userFile", new ActionError("file.name.enter")); 39 } 40 41 return errors; 42 } 43 44 48 public java.lang.String getFileName() 49 { 50 if (userFile != null) 51 { 52 return userFile.getFileName(); 53 } 54 55 return null; 56 } 57 58 62 public FormFile getUserFile() 63 { 64 return this.userFile; 65 } 66 67 71 public void setUserFile(FormFile userFile) 72 { 73 this.userFile = userFile; 74 } 75 76 public byte[] getFileBytes() throws FileNotFoundException, IOException 77 { 78 if (userFile != null) 79 { 80 return userFile.getFileData(); 81 } 82 83 return null; 84 } 85 86 public InputStream getFileStream() throws FileNotFoundException, IOException 87 { 88 if (userFile != null) 89 { 90 return userFile.getInputStream(); 91 } 92 93 return null; 94 } 95 96 public String getFileContentType() 97 { 98 if (userFile != null) 99 { 100 return userFile.getContentType(); 101 } 102 103 return null; 104 } 105 106 public int getFileSize() 107 { 108 if (userFile != null) 109 { 110 return userFile.getFileSize(); 111 } 112 113 return 0; 114 } 115 116 } 117 | Popular Tags |