01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.http;
04:
05: import java.io.File;
06: import fitnesse.util.FileUtil;
07:
08: public class UploadedFile {
09: private String name;
10:
11: private String type;
12:
13: private File file;
14:
15: public UploadedFile(String name, String type, File file) {
16: this .name = name;
17: this .type = type;
18: this .file = file;
19: }
20:
21: public String getName() {
22: return name;
23: }
24:
25: public String getType() {
26: return type;
27: }
28:
29: public File getFile() {
30: return file;
31: }
32:
33: public String toString() {
34: try {
35: return "name : " + getName() + "; type : " + getType()
36: + "; content : " + FileUtil.getFileContent(file);
37: } catch (Exception e) {
38: e.printStackTrace();
39: return e.toString();
40: }
41: }
42:
43: public boolean isUsable() {
44: return (name != null && name.length() > 0);
45: }
46:
47: public void delete() {
48: file.delete();
49: }
50: }
|