📄 defaultfileitem.html
字号:
<DT><B>Returns:</B><DD>The original filename in the client's filesystem.</DL>
</DD>
</DL>
<HR>
<A NAME="isInMemory()"><!-- --></A><H3>
isInMemory</H3>
<PRE>
public boolean <B>isInMemory</B>()</PRE>
<DL>
<DD>Provides a hint as to whether or not the file contents will be read from memory.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html#isInMemory()">isInMemory</A></CODE> in interface <CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html">FileItem</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD><code>true</code> if the file contents will be read from memory; <code>false</code> otherwise.</DL>
</DD>
</DL>
<HR>
<A NAME="getSize()"><!-- --></A><H3>
getSize</H3>
<PRE>
public long <B>getSize</B>()</PRE>
<DL>
<DD>Returns the size of the file.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html#getSize()">getSize</A></CODE> in interface <CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html">FileItem</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>The size of the file, in bytes.</DL>
</DD>
</DL>
<HR>
<A NAME="get()"><!-- --></A><H3>
get</H3>
<PRE>
public byte[] <B>get</B>()</PRE>
<DL>
<DD>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.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html#get()">get</A></CODE> in interface <CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html">FileItem</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>The contents of the file as an array of bytes.</DL>
</DD>
</DL>
<HR>
<A NAME="getString(java.lang.String)"><!-- --></A><H3>
getString</H3>
<PRE>
public java.lang.String <B>getString</B>(java.lang.String encoding) throws java.io.UnsupportedEncodingException</PRE>
<DL>
<DD>Returns the contents of the file as a String, using the specified encoding. This method uses <A HREF="../../../../org/apache/commons/fileupload/DefaultFileItem.html#get()"><CODE>get()</CODE></A> to retrieve the contents of the file.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html#getString(java.lang.String)">getString</A></CODE> in interface <CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html">FileItem</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>encoding</CODE> - The character encoding to use.<DT><B>Returns:</B><DD>The contents of the file, as a string.<DT><B>Throws:</B><DD><CODE>java.io.UnsupportedEncodingException</CODE> - if the requested character encoding is not available.</DL>
</DD>
</DL>
<HR>
<A NAME="getString()"><!-- --></A><H3>
getString</H3>
<PRE>
public java.lang.String <B>getString</B>()</PRE>
<DL>
<DD>Returns the contents of the file as a String, using the default character encoding. This method uses <A HREF="../../../../org/apache/commons/fileupload/DefaultFileItem.html#get()"><CODE>get()</CODE></A> to retrieve the contents of the file.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html#getString()">getString</A></CODE> in interface <CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html">FileItem</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>The contents of the file, as a string.</DL>
</DD>
</DL>
<HR>
<A NAME="write(java.io.File)"><!-- --></A><H3>
write</H3>
<PRE>
public void <B>write</B>(java.io.File file) throws java.lang.Exception</PRE>
<DL>
<DD>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. <p> 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. <p> This method is only guaranteed to work <em>once</em>, 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.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html#write(java.io.File)">write</A></CODE> in interface <CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html">FileItem</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>file</CODE> - The <code>File</code> into which the uploaded item should be stored.<DT><B>Throws:</B><DD><CODE>java.lang.Exception</CODE> - if an error occurs.</DL>
</DD>
</DL>
<HR>
<A NAME="delete()"><!-- --></A><H3>
delete</H3>
<PRE>
public void <B>delete</B>()</PRE>
<DL>
<DD>Deletes the underlying storage for a file item, including deleting any associated temporary disk file. Although this storage will be deleted automatically when the <code>FileItem</code> instance is garbage collected, this method can be used to ensure that this is done at an earlier time, thus preserving system resources.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html#delete()">delete</A></CODE> in interface <CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html">FileItem</A></CODE></DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getFieldName()"><!-- --></A><H3>
getFieldName</H3>
<PRE>
public java.lang.String <B>getFieldName</B>()</PRE>
<DL>
<DD>Returns the name of the field in the multipart form corresponding to this file item.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html#getFieldName()">getFieldName</A></CODE> in interface <CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html">FileItem</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>The name of the form field.<DT><B>See Also:</B><DD><A HREF="../../../../org/apache/commons/fileupload/DefaultFileItem.html#setFieldName(java.lang.String)"><CODE>setFieldName(java.lang.String)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="setFieldName(java.lang.String)"><!-- --></A><H3>
setFieldName</H3>
<PRE>
public void <B>setFieldName</B>(java.lang.String fieldName)</PRE>
<DL>
<DD>Sets the field name used to reference this file item.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html#setFieldName(java.lang.String)">setFieldName</A></CODE> in interface <CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html">FileItem</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>fieldName</CODE> - The name of the form field.<DT><B>See Also:</B><DD><A HREF="../../../../org/apache/commons/fileupload/DefaultFileItem.html#getFieldName()"><CODE>getFieldName()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="isFormField()"><!-- --></A><H3>
isFormField</H3>
<PRE>
public boolean <B>isFormField</B>()</PRE>
<DL>
<DD>Determines whether or not a <code>FileItem</code> instance represents a simple form field.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html#isFormField()">isFormField</A></CODE> in interface <CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html">FileItem</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD><code>true</code> if the instance represents a simple form field; <code>false</code> if it represents an uploaded file.<DT><B>See Also:</B><DD><A HREF="../../../../org/apache/commons/fileupload/DefaultFileItem.html#setFormField(boolean)"><CODE>setFormField(boolean)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="setFormField(boolean)"><!-- --></A><H3>
setFormField</H3>
<PRE>
public void <B>setFormField</B>(boolean state)</PRE>
<DL>
<DD>Specifies whether or not a <code>FileItem</code> instance represents a simple form field.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html#setFormField(boolean)">setFormField</A></CODE> in interface <CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html">FileItem</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>state</CODE> - <code>true</code> if the instance represents a simple form field; <code>false</code> if it represents an uploaded file.<DT><B>See Also:</B><DD><A HREF="../../../../org/apache/commons/fileupload/DefaultFileItem.html#isFormField()"><CODE>isFormField()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getOutputStream()"><!-- --></A><H3>
getOutputStream</H3>
<PRE>
public java.io.OutputStream <B>getOutputStream</B>() throws java.io.IOException</PRE>
<DL>
<DD>Returns an <CODE>OutputStream</CODE> that can be used for storing the contents of the file.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html#getOutputStream()">getOutputStream</A></CODE> in interface <CODE><A HREF="../../../../org/apache/commons/fileupload/FileItem.html">FileItem</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>An <CODE>OutputStream</CODE> that can be used for storing the contensts of the file.<DT><B>Throws:</B><DD><CODE>java.io.IOException</CODE> - if an error occurs.</DL>
</DD>
</DL>
<HR>
<A NAME="getStoreLocation()"><!-- --></A><H3>
getStoreLocation</H3>
<PRE>
public java.io.File <B>getStoreLocation</B>()</PRE>
<DL>
<DD>Returns the <CODE>File</CODE> object for the <code>FileItem</code>'s data's temporary location on the disk. Note that for <code>FileItem</code>s that have their data stored in memory, this method will return <code>null</code>. When handling large files, you can use <CODE>File.renameTo(java.io.File)</CODE> to move the file to new location without copying the data, if the source and destination locations reside within the same logical volume.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>The data file, or <code>null</code> if the data is stored in memory.</DL>
</DD>
</DL>
<HR>
<A NAME="finalize()"><!-- --></A><H3>
finalize</H3>
<PRE>
protected void <B>finalize</B>()</PRE>
<DL>
<DD>Removes the file contents from the temporary storage.
<P>
<DD><DL>
<DT><B>Overrides:</B><DD><CODE>finalize</CODE> in class <CODE>java.lang.Object</CODE></DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getTempFile()"><!-- --></A><H3>
getTempFile</H3>
<PRE>
protected java.io.File <B>getTempFile</B>()</PRE>
<DL>
<DD>Creates and returns a <CODE>File</CODE> representing a uniquely named temporary file in the configured repository path.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>The <CODE>File</CODE> to be used for temporary storage.</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/DefaultFileItem.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
PREV CLASS
<A HREF="../../../../org/apache/commons/fileupload/DefaultFileItemFactory.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html" TARGET="_top"><B>FRAMES</B></A>
<A HREF="DefaultFileItem.html" TARGET="_top"><B>NO FRAMES</B></A>
<SCRIPT> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT><A HREF="../../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A></NOSCRIPT></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
Copyright © 2002-2003 Apache Software Foundation. All Rights Reserved.
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -