Java Doc for DefaultFileItem.java in  » J2EE » WiSerFramework » de » ug2t » extTools » httpFileUpLoad » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » WiSerFramework » de.ug2t.extTools.httpFileUpLoad 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   de.ug2t.extTools.httpFileUpLoad.DefaultFileItem

DefaultFileItem
public class DefaultFileItem implements FileItem(Code)

The default implementation of the org.apache.commons.fileupload.FileItem FileItem interface.

After retrieving an instance of this class from a org.apache.commons.fileupload.DiskFileUpload DiskFileUpload instance (see org.apache.commons.fileupload.DiskFileUpload.parseRequest(javax.servlet.http.HttpServletRequest) ), you may either request all contents of file at once using DefaultFileItem.get() or request an java.io.InputStream InputStream with DefaultFileItem.getInputStream() and process the file without attempting to load it into memory, which may come handy with large files.
author:
   Rafal Krzewski
author:
   Sean Legassick
author:
   Jason van Zyl
author:
   John McNally
author:
   Martin Cooper
author:
   Sean C. Sullivan
version:
   $Id: DefaultFileItem.java,v 1.21 2003/06/24 05:45:15 martinc Exp $




Constructor Summary
 DefaultFileItem(String fieldName, String contentType, boolean isFormField, String fileName, int sizeThreshold, File repository)
     Constructs a new DefaultFileItem instance.

Method Summary
public  voiddelete()
     Deletes the underlying storage for a file item, including deleting any associated temporary disk file.
protected  voidfinalize()
     Removes the file contents from the temporary storage.
public  byte[]get()
     Returns the contents of the file as an array of bytes.
public  StringgetContentType()
     Returns the content type passed by the browser or null if not defined.
public  StringgetFieldName()
     Returns the name of the field in the multipart form corresponding to this file item.
public  InputStreamgetInputStream()
     Returns an java.io.InputStream InputStream that can be used to retrieve the contents of the file.
public  StringgetName()
     Returns the original filename in the client's filesystem.
public  OutputStreamgetOutputStream()
     Returns an java.io.OutputStream OutputStream that can be used for storing the contents of the file.
public  longgetSize()
     Returns the size of the file.
public  FilegetStoreLocation()
     Returns the java.io.File object for the FileItem's data's temporary location on the disk.
public  StringgetString(String encoding)
     Returns the contents of the file as a String, using the specified encoding. This method uses DefaultFileItem.get() to retrieve the contents of the file.
Parameters:
  encoding - The character encoding to use.
public  StringgetString()
     Returns the contents of the file as a String, using the default character encoding.
protected  FilegetTempFile()
     Creates and returns a java.io.File File representing a uniquely named temporary file in the configured repository path.
public  booleanisFormField()
     Determines whether or not a FileItem instance represents a simple form field.
public  booleanisInMemory()
     Provides a hint as to whether or not the file contents will be read from memory.
public  voidsetFieldName(String fieldName)
     Sets the field name used to reference this file item.
public  voidsetFormField(boolean state)
     Specifies whether or not a FileItem instance represents a simple form field.
public  voidwrite(File file)
     A convenience method to write an uploaded item to disk.


Constructor Detail
DefaultFileItem
DefaultFileItem(String fieldName, String contentType, boolean isFormField, String fileName, int sizeThreshold, File repository)(Code)
Constructs a new DefaultFileItem instance.
Parameters:
  fieldName - The name of the form field.
Parameters:
  contentType - The content type passed by the browser or null ifnot specified.
Parameters:
  isFormField - Whether or not this item is a plain form field, as opposed to afile upload.
Parameters:
  fileName - The original filename in the user's filesystem, ornull if not specified.
Parameters:
  sizeThreshold - The threshold, in bytes, below which items will be retained inmemory and above which they will be stored as a file.
Parameters:
  repository - The data repository, which is the directory in which files will becreated, should the item size exceed the threshold.




Method Detail
delete
public void delete()(Code)
Deletes the underlying storage for a file item, including deleting any associated temporary disk file. Although this storage will be deleted automatically when the FileItem instance is garbage collected, this method can be used to ensure that this is done at an earlier time, thus preserving system resources.



finalize
protected void finalize()(Code)
Removes the file contents from the temporary storage.



get
public byte[] get()(Code)
Returns the contents of the file as an array of bytes. If the contents of the file were not yet cached in memory, they will be loaded from the disk storage and cached. The contents of the file as an array of bytes.



getContentType
public String getContentType()(Code)
Returns the content type passed by the browser or null if not defined. The content type passed by the browser or null ifnot defined.



getFieldName
public String getFieldName()(Code)
Returns the name of the field in the multipart form corresponding to this file item. The name of the form field.
See Also:   DefaultFileItem.setFieldName(java.lang.String)



getInputStream
public InputStream getInputStream() throws IOException(Code)
Returns an java.io.InputStream InputStream that can be used to retrieve the contents of the file. An java.io.InputStream InputStream that can be used toretrieve the contents of the file.
exception:
  IOException - if an error occurs.



getName
public String getName()(Code)
Returns the original filename in the client's filesystem. The original filename in the client's filesystem.



getOutputStream
public OutputStream getOutputStream() throws IOException(Code)
Returns an java.io.OutputStream OutputStream that can be used for storing the contents of the file. An java.io.OutputStream OutputStream that can be used forstoring the contensts of the file.
exception:
  IOException - if an error occurs.



getSize
public long getSize()(Code)
Returns the size of the file. The size of the file, in bytes.



getStoreLocation
public File getStoreLocation()(Code)
Returns the java.io.File object for the FileItem's data's temporary location on the disk. Note that for FileItems that have their data stored in memory, this method will return null. When handling large files, you can use java.io.File.renameTo(java.io.File) to move the file to new location without copying the data, if the source and destination locations reside within the same logical volume. The data file, or null if the data is stored inmemory.



getString
public String getString(String encoding) throws UnsupportedEncodingException(Code)
Returns the contents of the file as a String, using the specified encoding. This method uses DefaultFileItem.get() to retrieve the contents of the file.
Parameters:
  encoding - The character encoding to use. The contents of the file, as a string.
exception:
  UnsupportedEncodingException - if the requested character encoding is not available.



getString
public String getString()(Code)
Returns the contents of the file as a String, using the default character encoding. This method uses DefaultFileItem.get() to retrieve the contents of the file. The contents of the file, as a string.



getTempFile
protected File getTempFile()(Code)
Creates and returns a java.io.File File representing a uniquely named temporary file in the configured repository path. The java.io.File File to be used for temporary storage.



isFormField
public boolean isFormField()(Code)
Determines whether or not a FileItem instance represents a simple form field. true if the instance represents a simple form field;false if it represents an uploaded file.
See Also:   DefaultFileItem.setFormField(boolean)



isInMemory
public boolean isInMemory()(Code)
Provides a hint as to whether or not the file contents will be read from memory. true if the file contents will be read from memory;false otherwise.



setFieldName
public void setFieldName(String fieldName)(Code)
Sets the field name used to reference this file item.
Parameters:
  fieldName - The name of the form field.
See Also:   DefaultFileItem.getFieldName()



setFormField
public void setFormField(boolean state)(Code)
Specifies whether or not a FileItem instance represents a simple form field.
Parameters:
  state - true if the instance represents a simple formfield; false if it represents an uploaded file.
See Also:   DefaultFileItem.isFormField()



write
public void write(File file) throws Exception(Code)
A convenience method to write an uploaded item to disk. The client code is not concerned with whether or not the item is stored in memory, or on disk in a temporary location. They just want to write the uploaded item to a file.

This implementation first attempts to rename the uploaded item to the specified destination file, if the item was originally written to disk. Otherwise, the data will be copied to the specified file.

This method is only guaranteed to Work once, the first time it is invoked for a particular item. This is because, in the event that the method renames a temporary file, that file will no longer be available to copy or rename again at a later time.
Parameters:
  file - The File into which the uploaded item should bestored.
exception:
  Exception - if an error occurs.




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.