📄 datahandler.html
字号:
<TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/activation/DataHandler.html#setCommandMap(javax.activation.CommandMap)">setCommandMap</A></B>(<A HREF="../../javax/activation/CommandMap.html" title="class in javax.activation">CommandMap</A> commandMap)</CODE><BR> Set the CommandMap for use by this DataHandler.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static void</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/activation/DataHandler.html#setDataContentHandlerFactory(javax.activation.DataContentHandlerFactory)">setDataContentHandlerFactory</A></B>(<A HREF="../../javax/activation/DataContentHandlerFactory.html" title="interface in javax.activation">DataContentHandlerFactory</A> newFactory)</CODE><BR> Sets the DataContentHandlerFactory.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../javax/activation/DataHandler.html#writeTo(java.io.OutputStream)">writeTo</A></B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/OutputStream.html" title="class or interface in java.io">OutputStream</A> os)</CODE><BR> Write the data to an <code>OutputStream</code>.</TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></B></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD></TR></TABLE> <P><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TH></TR></TABLE><A NAME="DataHandler(javax.activation.DataSource)"><!-- --></A><H3>DataHandler</H3><PRE>public <B>DataHandler</B>(<A HREF="../../javax/activation/DataSource.html" title="interface in javax.activation">DataSource</A> ds)</PRE><DL><DD>Create a <code>DataHandler</code> instance referencing the specified DataSource. The data exists in a byte stream form. The DataSource will provide an InputStream to access the data.<P><DL><DT><B>Parameters:</B><DD><CODE>ds</CODE> - the DataSource</DL></DL><HR><A NAME="DataHandler(java.lang.Object, java.lang.String)"><!-- --></A><H3>DataHandler</H3><PRE>public <B>DataHandler</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A> obj, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> mimeType)</PRE><DL><DD>Create a <code>DataHandler</code> instance representing an object of this MIME type. This constructor is used when the application already has an in-memory representation of the data in the form of a Java Object.<P><DL><DT><B>Parameters:</B><DD><CODE>obj</CODE> - the Java Object<DD><CODE>mimeType</CODE> - the MIME type of the object</DL></DL><HR><A NAME="DataHandler(java.net.URL)"><!-- --></A><H3>DataHandler</H3><PRE>public <B>DataHandler</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/net/URL.html" title="class or interface in java.net">URL</A> url)</PRE><DL><DD>Create a <code>DataHandler</code> instance referencing a URL. The DataHandler internally creates a <code>URLDataSource</code> instance to represent the URL.<P><DL><DT><B>Parameters:</B><DD><CODE>url</CODE> - a URL object</DL></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>Method Detail</B></FONT></TH></TR></TABLE><A NAME="getDataSource()"><!-- --></A><H3>getDataSource</H3><PRE>public <A HREF="../../javax/activation/DataSource.html" title="interface in javax.activation">DataSource</A> <B>getDataSource</B>()</PRE><DL><DD>Return the DataSource associated with this instance of DataHandler. <p> For DataHandlers that have been instantiated with a DataSource, this method returns the DataSource that was used to create the DataHandler object. In other cases the DataHandler constructs a DataSource from the data used to construct the DataHandler. DataSources created for DataHandlers <b>not</b> instantiated with a DataSource are cached for performance reasons.<P><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>a valid DataSource object for this DataHandler</DL></DD></DL><HR><A NAME="getName()"><!-- --></A><H3>getName</H3><PRE>public <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getName</B>()</PRE><DL><DD>Return the name of the data object. If this DataHandler was created with a DataSource, this method calls through to the <code>DataSource.getName</code> method, otherwise it returns <i>null</i>.<P><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the name of the object</DL></DD></DL><HR><A NAME="getContentType()"><!-- --></A><H3>getContentType</H3><PRE>public <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getContentType</B>()</PRE><DL><DD>Return the MIME type of this object as retrieved from the source object. Note that this is the <i>full</i> type with parameters.<P><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the MIME type</DL></DD></DL><HR><A NAME="getInputStream()"><!-- --></A><H3>getInputStream</H3><PRE>public <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/InputStream.html" title="class or interface in java.io">InputStream</A> <B>getInputStream</B>() throws <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></PRE><DL><DD>Get the InputStream for this object. <p> For DataHandlers instantiated with a DataSource, the DataHandler calls the <code>DataSource.getInputStream</code> method and returns the result to the caller. <p> For DataHandlers instantiated with an Object, the DataHandler first attempts to find a DataContentHandler for the Object. If the DataHandler can not find a DataContentHandler for this MIME type, it throws an UnsupportedDataTypeException. If it is successful, it creates a pipe and a thread. The thread uses the DataContentHandler's <code>writeTo</code> method to write the stream data into one end of the pipe. The other end of the pipe is returned to the caller. Because a thread is created to copy the data, IOExceptions that may occur during the copy can not be propagated back to the caller. The result is an empty stream.<p><P><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the InputStream representing this data<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></CODE> - if an I/O error occurs<DT><B>See Also:</B><DD><A HREF="../../javax/activation/DataContentHandler.html#writeTo(java.lang.Object, java.lang.String, java.io.OutputStream)"><CODE>DataContentHandler.writeTo(java.lang.Object, java.lang.String, java.io.OutputStream)</CODE></A>, <A HREF="../../javax/activation/UnsupportedDataTypeException.html" title="class in javax.activation"><CODE>UnsupportedDataTypeException</CODE></A></DL></DD></DL><HR><A NAME="writeTo(java.io.OutputStream)"><!-- --></A><H3>writeTo</H3><PRE>public void <B>writeTo</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/OutputStream.html" title="class or interface in java.io">OutputStream</A> os) throws <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></PRE><DL><DD>Write the data to an <code>OutputStream</code>.<p> If the DataHandler was created with a DataSource, writeTo retrieves the InputStream and copies the bytes from the InputStream to the OutputStream passed in. <p> If the DataHandler was created with an object, writeTo retrieves the DataContentHandler for the object's type. If the DataContentHandler was found, it calls the <code>writeTo</code> method on the <code>DataContentHandler</code>.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>os</CODE> - the OutputStream to write to<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></CODE> - if an I/O error occurs</DL></DD></DL><HR><A NAME="getOutputStream()"><!-- --></A><H3>getOutputStream</H3><PRE>public <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/OutputStream.html" title="class or interface in java.io">OutputStream</A> <B>getOutputStream</B>() throws <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></PRE><DL><DD>Get an OutputStream for this DataHandler to allow overwriting the underlying data. If the DataHandler was created with a DataSource, the DataSource's <code>getOutputStream</code> method is called. Otherwise, <code>null</code> is returned.<P><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the OutputStream<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></CODE><DT><B>See Also:</B><DD><A HREF="../../javax/activation/DataSource.html#getOutputStream()"><CODE>DataSource.getOutputStream()</CODE></A>, <A HREF="../../javax/activation/URLDataSource.html" title="class in javax.activation"><CODE>URLDataSource</CODE></A></DL></DD></DL><HR><A NAME="getTransferDataFlavors()"><!-- --></A><H3>getTransferDataFlavors</H3><PRE>public <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/awt/datatransfer/DataFlavor.html" title="class or interface in java.awt.datatransfer">DataFlavor</A>[] <B>getTransferDataFlavors</B>()</PRE><DL><DD>Return the DataFlavors in which this data is available. <p> Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The array is usually ordered according to preference for providing the data, from most richly descriptive to least richly descriptive.<p> The DataHandler attempts to find a DataContentHandler that corresponds to the MIME type of the data. If one is located, the DataHandler calls the DataContentHandler's <code>getTransferDataFlavors</code> method. <p> If a DataContentHandler can <i>not</i> be located, and if the DataHandler was created with a DataSource (or URL), one DataFlavor is returned that represents this object's MIME type and the <code>java.io.InputStream</code> class. If the DataHandler was created with an object and a MIME type, getTransferDataFlavors returns one DataFlavor that represents this object's MIME type and the object's class.<P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/awt/datatransfer/Transferable.html#getTransferDataFlavors()" title="class or interface in java.awt.datatransfer">getTransferDataFlavors</A></CODE> in interface <CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/awt/datatransfer/Transferable.html" title="class or interface in java.awt.datatransfer">Transferable</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>an array of data flavors in which this data can be transferred<DT><B>See Also:</B><DD><A HREF="../../javax/activation/DataContentHandler.html#getTransferDataFlavors()"><CODE>DataContentHandler.getTransferDataFlavors()</CODE></A></DL></DD></DL><HR><A NAME="isDataFlavorSupported(java.awt.datatransfer.DataFlavor)"><!-- --></A><H3>isDataFlavorSupported</H3><PRE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -