📄 file.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 Apr 27 23:34:40 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class File</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="class-use/File.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-files/index-1.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><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../java/io/DataOutputStream.html"><B>PREV CLASS</B></A> <A HREF="../../java/io/FileDescriptor.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="File.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <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">java.io</FONT><BR>Class File</H2><PRE><A HREF="../../java/lang/Object.html">java.lang.Object</A> | +--<B>java.io.File</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../java/lang/Comparable.html">Comparable</A>, <A HREF="../../java/io/Serializable.html">Serializable</A></DD></DL><HR><DL><DT>public class <B>File</B><DT>extends <A HREF="../../java/lang/Object.html">Object</A><DT>implements <A HREF="../../java/io/Serializable.html">Serializable</A>, <A HREF="../../java/lang/Comparable.html">Comparable</A></DL><P>An abstract representation of file and directory pathnames. <p> User interfaces and operating systems use system-dependent <em>pathname strings</em> to name files and directories. This class presents an abstract, system-independent view of hierarchical pathnames. An <em>abstract pathname</em> has two components: <ol> <li> An optional system-dependent <em>prefix</em> string,<br> such as a disk-drive specifier, <code>"/"</code> for the UNIX root directory, or <code>"\\"</code> for a Win32 UNC pathname, and <li> A sequence of zero or more string <em>names</em>. </ol> Each name in an abstract pathname except for the last denotes a directory; the last name may denote either a directory or a file. The <em>empty</em> abstract pathname has no prefix and an empty name sequence. <p> The conversion of a pathname string to or from an abstract pathname is inherently system-dependent. When an abstract pathname is converted into a pathname string, each name is separated from the next by a single copy of the default <em>separator character</em>. The default name-separator character is defined by the system property <code>file.separator</code>, and is made available in the public static fields <code><A HREF="../../java/io/File.html#separator"><CODE>separator</CODE></A></code> and <code><A HREF="../../java/io/File.html#separatorChar"><CODE>separatorChar</CODE></A></code> of this class. When a pathname string is converted into an abstract pathname, the names within it may be separated by the default name-separator character or by any other name-separator character that is supported by the underlying system. <p> A pathname, whether abstract or in string form, may be either <em>absolute</em> or <em>relative</em>. An absolute pathname is complete in that no other information is required in order to locate the file that it denotes. A relative pathname, in contrast, must be interpreted in terms of information taken from some other pathname. By default the classes in the <code>java.io</code> package always resolve relative pathnames against the current user directory. This directory is named by the system property <code>user.dir</code>, and is typically the directory in which the Java virtual machine was invoked. <p> The prefix concept is used to handle root directories on UNIX platforms, and drive specifiers, root directories and UNC pathnames on Win32 platforms, as follows: <ul> <li> For UNIX platforms, the prefix of an absolute pathname is always <code>"/"</code>. Relative pathnames have no prefix. The abstract pathname denoting the root directory has the prefix <code>"/"</code> and an empty name sequence. <li> For Win32 platforms, the prefix of a pathname that contains a drive specifier consists of the drive letter followed by <code>":"</code> and possibly followed by <code>"\"</code> if the pathname is absolute. The prefix of a UNC pathname is <code>"\\"</code>; the hostname and the share name are the first two names in the name sequence. A relative pathname that does not specify a drive has no prefix. </ul> <p> Instances of the <code>File</code> class are immutable; that is, once created, the abstract pathname represented by a <code>File</code> object will never change.<P><DL><DT><B>Since: </B><DD>JDK1.0</DD><DT><B>See Also: </B><DD><A HREF="../../serialized-form.html#java.io.File">Serialized Form</A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/File.html#pathSeparator">pathSeparator</A></B></CODE><BR> The system-dependent path-separator character, represented as a string for convenience.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static char</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/File.html#pathSeparatorChar">pathSeparatorChar</A></B></CODE><BR> The system-dependent path-separator character.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/File.html#separator">separator</A></B></CODE><BR> The system-dependent default name-separator character, represented as a string for convenience.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static char</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/File.html#separatorChar">separatorChar</A></B></CODE><BR> The system-dependent default name-separator character.</TD></TR></TABLE> <!-- ======== 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="../../java/io/File.html#File(java.io.File, java.lang.String)">File</A></B>(<A HREF="../../java/io/File.html">File</A> parent, <A HREF="../../java/lang/String.html">String</A> child)</CODE><BR> Creates a new <code>File</code> instance from a parent abstract pathname and a child pathname string.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../java/io/File.html#File(java.lang.String)">File</A></B>(<A HREF="../../java/lang/String.html">String</A> pathname)</CODE><BR> Creates a new <code>File</code> instance by converting the given pathname string into an abstract pathname.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../java/io/File.html#File(java.lang.String, java.lang.String)">File</A></B>(<A HREF="../../java/lang/String.html">String</A> parent, <A HREF="../../java/lang/String.html">String</A> child)</CODE><BR> Creates a new <code>File</code> instance from a parent pathname string and a child pathname string.</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> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/File.html#canRead()">canRead</A></B>()</CODE><BR> Tests whether the application can read the file denoted by this abstract pathname.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/File.html#canWrite()">canWrite</A></B>()</CODE><BR> Tests whether the application can modify to the file denoted by this abstract pathname.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/File.html#compareTo(java.io.File)">compareTo</A></B>(<A HREF="../../java/io/File.html">File</A> pathname)</CODE><BR> Compares two abstract pathnames lexicographically.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/File.html#compareTo(java.lang.Object)">compareTo</A></B>(<A HREF="../../java/lang/Object.html">Object</A> o)</CODE><BR> Compares this abstract pathname to another object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/File.html#createNewFile()">createNewFile</A></B>()</CODE><BR> Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -