Author: nbelaevski
Date: 2008-12-07 09:49:33 -0500 (Sun, 07 Dec 2008)
New Revision: 11617
Modified:
trunk/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java
Log:
FileUploadDemo bean enhancement
Modified: trunk/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java 2008-12-07 14:07:17
UTC (rev 11616)
+++ trunk/samples/fileUploadDemo/src/main/java/org/richfaces/Bean.java 2008-12-07 14:49:33
UTC (rev 11617)
@@ -27,6 +27,7 @@
import java.io.InputStream;
import java.rmi.server.UID;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -76,9 +77,16 @@
file.delete();
}else {
try {
- ByteArrayOutputStream b = new ByteArrayOutputStream();
- b.write(item.getData());
- System.out.println(b.toString());
+ byte[] bytes = item.getData();
+ int numberOfBytes = 256;
+
+ if (bytes.length > numberOfBytes) {
+ System.out.println("First " + numberOfBytes + " bytes of uploaded
file:");
+ System.out.println(new String(bytes, 0, numberOfBytes));
+ } else {
+ System.out.println("Uploaded file contents:");
+ System.out.println(new String(bytes, 0, bytes.length));
+ }
} catch (Exception e) {
// TODO: handle exception
}
Show replies by date