java
The FileVO class is a value object that describes a single file. Rather than use the Java standard
File class, I created my own VO so that I could include only that information I was interested
in about a file, and any extra that the File class didn??™t provide.
The FileVO class is basically just a typical javabean with private fields and a bunch of getters
and setters. You??™ll also find my usual toString() implementation floating around. The one
exception to this typicality (is that a word?) is the setType() method, which is this code:
public void setType(final String inType) {
// If inType is null, we'll dynamically try and detect the file type.
// Otherwise we'll just set the type to the value of inType.
if (inType == null && name != null) {
String fileExtension = "";
int dotLocation = name.lastIndexOf(".");
if (dotLocation != -1) {
fileExtension = name.substring(dotLocation + 1);
}
type = "Unknown File";
if (fileExtension.equalsIgnoreCase("txt")) {
type = "Text Document";
} else if (fileExtension.equalsIgnoreCase("zip")) {
type = "Zip Archive";
} else if (fileExtension.equalsIgnoreCase("pdf")) {
type = "Adobe Acrobat Document";
...
} else if (fileExtension.
Pages:
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563