📄 mimetypesfiletypemap.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc on Thu Jan 17 03:51:30 PST 2002 -->
<TITLE>
Java 2 Platform EE v1.3: Class MimetypesFileTypeMap
</TITLE>
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">
</HEAD>
<BODY BGCOLOR="white">
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_top"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<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="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">
<A HREF="../../javax/activation/MimeTypeParameterList.html"><B>PREV CLASS</B></A>
<A HREF="../../javax/activation/URLDataSource.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="MimetypesFileTypeMap.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
javax.activation</FONT>
<BR>
Class MimetypesFileTypeMap</H2>
<PRE>
java.lang.Object
|
+--<A HREF="../../javax/activation/FileTypeMap.html">javax.activation.FileTypeMap</A>
|
+--<B>javax.activation.MimetypesFileTypeMap</B>
</PRE>
<HR>
<DL>
<DT>public class <B>MimetypesFileTypeMap</B><DT>extends <A HREF="../../javax/activation/FileTypeMap.html">FileTypeMap</A></DL>
<P>
This class extends FileTypeMap and provides data typing of files
via their file extension. It uses the <code>.mime.types</code> format. <p>
<b>MIME types file search order:</b><p>
The MimetypesFileTypeMap looks in various places in the user's
system for MIME types file entries. When requests are made
to search for MIME types in the MimetypesFileTypeMap, it searches
MIME types files in the following order:
<p>
<ol>
<li> Programmatically added entries to the MimetypesFileTypeMap instance.
<li> The file <code>.mime.types</code> in the user's home directory.
<li> The file <<i>java.home</i>><code>/lib/mime.types</code>.
<li> The file or resource named <code>META-INF/mime.types</code>.
<li> The file or resource named <code>META-INF/mimetypes.default</code>
(usually found only in the <code>activation.jar</code> file).
</ol>
<p>
<b>MIME types file format:</b><p>
<code>
# comments begin with a '#'<br>
# the format is <mime type> <space separated file extensions><br>
# for example:<br>
text/plain txt text TXT<br>
# this would map file.txt, file.text, and file.TXT to<br>
# the mime type "text/plain"<br>
</code>
<P>
<HR>
<P>
<!-- ======== INNER CLASS SUMMARY ======== -->
<!-- =========== FIELD SUMMARY =========== -->
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../javax/activation/MimetypesFileTypeMap.html#MimetypesFileTypeMap()">MimetypesFileTypeMap</A></B>()</CODE>
<BR>
The default constructor.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../javax/activation/MimetypesFileTypeMap.html#MimetypesFileTypeMap(java.io.InputStream)">MimetypesFileTypeMap</A></B>(java.io.InputStream is)</CODE>
<BR>
Construct a MimetypesFileTypeMap with programmatic entries
added from the InputStream.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../javax/activation/MimetypesFileTypeMap.html#MimetypesFileTypeMap(java.lang.String)">MimetypesFileTypeMap</A></B>(java.lang.String mimeTypeFileName)</CODE>
<BR>
Construct a MimetypesFileTypeMap with programmatic entries
added from the named file.</TD>
</TR>
</TABLE>
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></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/MimetypesFileTypeMap.html#addMimeTypes(java.lang.String)">addMimeTypes</A></B>(java.lang.String mime_types)</CODE>
<BR>
Prepend the MIME type values to the registry.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/activation/MimetypesFileTypeMap.html#getContentType(java.io.File)">getContentType</A></B>(java.io.File f)</CODE>
<BR>
Return the MIME type of the file object.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/activation/MimetypesFileTypeMap.html#getContentType(java.lang.String)">getContentType</A></B>(java.lang.String filename)</CODE>
<BR>
Return the MIME type based on the specified file name.</TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_javax.activation.FileTypeMap"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class javax.activation.<A HREF="../../javax/activation/FileTypeMap.html">FileTypeMap</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../javax/activation/FileTypeMap.html#getDefaultFileTypeMap()">getDefaultFileTypeMap</A>, <A HREF="../../javax/activation/FileTypeMap.html#setDefaultFileTypeMap(javax.activation.FileTypeMap)">setDefaultFileTypeMap</A></CODE></TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class java.lang.Object</B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
<P>
<!-- ============ FIELD DETAIL =========== -->
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="MimetypesFileTypeMap()"><!-- --></A><H3>
MimetypesFileTypeMap</H3>
<PRE>
public <B>MimetypesFileTypeMap</B>()</PRE>
<DL>
<DD>The default constructor.</DL>
<HR>
<A NAME="MimetypesFileTypeMap(java.lang.String)"><!-- --></A><H3>
MimetypesFileTypeMap</H3>
<PRE>
public <B>MimetypesFileTypeMap</B>(java.lang.String mimeTypeFileName)
throws java.io.IOException</PRE>
<DL>
<DD>Construct a MimetypesFileTypeMap with programmatic entries
added from the named file.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>mimeTypeFileName</CODE> - the file name</DL>
</DD>
</DL>
<HR>
<A NAME="MimetypesFileTypeMap(java.io.InputStream)"><!-- --></A><H3>
MimetypesFileTypeMap</H3>
<PRE>
public <B>MimetypesFileTypeMap</B>(java.io.InputStream is)</PRE>
<DL>
<DD>Construct a MimetypesFileTypeMap with programmatic entries
added from the InputStream.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>is</CODE> - the input stream to read from</DL>
</DD>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="addMimeTypes(java.lang.String)"><!-- --></A><H3>
addMimeTypes</H3>
<PRE>
public void <B>addMimeTypes</B>(java.lang.String mime_types)</PRE>
<DL>
<DD>Prepend the MIME type values to the registry.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>mime_types</CODE> - A .mime.types formatted string of entries.</DL>
</DD>
</DL>
<HR>
<A NAME="getContentType(java.io.File)"><!-- --></A><H3>
getContentType</H3>
<PRE>
public java.lang.String <B>getContentType</B>(java.io.File f)</PRE>
<DL>
<DD>Return the MIME type of the file object.
The implementation in this class calls
<code>getContentType(f.getName())</code>.<DD><DL>
<DT><B>Overrides:</B><DD><CODE><A HREF="../../javax/activation/FileTypeMap.html#getContentType(java.io.File)">getContentType</A></CODE> in class <CODE><A HREF="../../javax/activation/FileTypeMap.html">FileTypeMap</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>f</CODE> - the file<DT><B>Returns:</B><DD>the file's MIME type</DL>
</DD>
</DL>
<HR>
<A NAME="getContentType(java.lang.String)"><!-- --></A><H3>
getContentType</H3>
<PRE>
public java.lang.String <B>getContentType</B>(java.lang.String filename)</PRE>
<DL>
<DD>Return the MIME type based on the specified file name.
The MIME type entries are searched as described above under
<i>MIME types file search order</i>.
If no entry is found, the type "application/octet-stream" is returned.<DD><DL>
<DT><B>Overrides:</B><DD><CODE><A HREF="../../javax/activation/FileTypeMap.html#getContentType(java.lang.String)">getContentType</A></CODE> in class <CODE><A HREF="../../javax/activation/FileTypeMap.html">FileTypeMap</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>filename</CODE> - the file name<DT><B>Returns:</B><DD>the file's MIME type</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=2 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="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<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="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">
<A HREF="../../javax/activation/MimeTypeParameterList.html"><B>PREV CLASS</B></A>
<A HREF="../../javax/activation/URLDataSource.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="MimetypesFileTypeMap.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -