📄 file.html
字号:
absolute if its prefix is <code>"/"</code>. On Win32 systems, a pathname is absolute if its prefix is a drive specifier followed by <code>"\\"</code>, or if its prefix is <code>"\\"</code>.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD><code>true</code> if this abstract pathname is absolute, <code>false</code> otherwise</DL></DD></DL><HR><A NAME="getAbsolutePath()"><!-- --></A><H3>getAbsolutePath</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>getAbsolutePath</B>()</PRE><DL><DD>Returns the absolute pathname string of this abstract pathname. <p> If this abstract pathname is already absolute, then the pathname string is simply returned as if by the <code><A HREF="../../java/io/File.html#getPath()"><CODE>getPath()</CODE></A></code> method. If this abstract pathname is the empty abstract pathname then the pathname string of the current user directory, which is named by the system property <code>user.dir</code>, is returned. Otherwise this pathname is resolved in a system-dependent way. On UNIX systems, a relative pathname is made absolute by resolving it against the current user directory. On Win32 systems, a relative pathname is made absolute by resolving it against the current directory of the drive named by the pathname, if any; if not, it is resolved against the current user directory.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>The absolute pathname string denoting the same file or directory as this abstract pathname<DT><B>See Also: </B><DD><A HREF="../../java/io/File.html#isAbsolute()"><CODE>isAbsolute()</CODE></A></DL></DD></DL><HR><A NAME="getAbsoluteFile()"><!-- --></A><H3>getAbsoluteFile</H3><PRE>public <A HREF="../../java/io/File.html">File</A> <B>getAbsoluteFile</B>()</PRE><DL><DD>Returns the absolute form of this abstract pathname. Equivalent to <code>new File(this.<A HREF="../../java/io/File.html#getAbsolutePath()"><CODE>getAbsolutePath()</CODE></A>())</code>.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>The absolute abstract pathname denoting the same file or directory as this abstract pathname<DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="getCanonicalPath()"><!-- --></A><H3>getCanonicalPath</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>getCanonicalPath</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Returns the canonical pathname string of this abstract pathname. <p> The precise definition of canonical form is system-dependent, but canonical forms are always absolute. Thus if this abstract pathname is relative it will be converted to absolute form as if by the <code><A HREF="../../java/io/File.html#getAbsoluteFile()"><CODE>getAbsoluteFile()</CODE></A></code> method. <p> Every pathname that denotes an existing file or directory has a unique canonical form. Every pathname that denotes a nonexistent file or directory also has a unique canonical form. The canonical form of the pathname of a nonexistent file or directory may be different from the canonical form of the same pathname after the file or directory is created. Similarly, the canonical form of the pathname of an existing file or directory may be different from the canonical form of the same pathname after the file or directory is deleted.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>The canonical pathname string denoting the same file or directory as this abstract pathname<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - If an I/O error occurs, which is possible because the construction of the canonical pathname may require filesystem queries<DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></DL><HR><A NAME="getCanonicalFile()"><!-- --></A><H3>getCanonicalFile</H3><PRE>public <A HREF="../../java/io/File.html">File</A> <B>getCanonicalFile</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Returns the canonical form of this abstract pathname. Equivalent to <code>new File(this.<A HREF="../../java/io/File.html#getCanonicalPath()"><CODE>getCanonicalPath()</CODE></A>())</code>.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>The canonical pathname string denoting the same file or directory as this abstract pathname<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - If an I/O error occurs, which is possible because the construction of the canonical pathname may require filesystem queries<DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="toURL()"><!-- --></A><H3>toURL</H3><PRE>public <A HREF="../../java/net/URL.html">URL</A> <B>toURL</B>() throws <A HREF="../../java/net/MalformedURLException.html">MalformedURLException</A></PRE><DL><DD>Converts this abstract pathname into a <code>file:</code> URL. The exact form of the URL is system-dependent. If it can be determined that the file denoted by this abstract pathname is a directory, then the resulting URL will end with a slash.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>a URL object representing the equivalent file URL.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/net/MalformedURLException.html">MalformedURLException</A></CODE> - if the path cannot be parsed as a URL.<DT><B>Since: </B><DD>1.2</DD><DT><B>See Also: </B><DD><A HREF="../../java/net/URL.html"><CODE>URL</CODE></A></DL></DD></DL><HR><A NAME="canRead()"><!-- --></A><H3>canRead</H3><PRE>public boolean <B>canRead</B>()</PRE><DL><DD>Tests whether the application can read the file denoted by this abstract pathname.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD><code>true</code> if and only if the file specified by this abstract pathname exists <em>and</em> can be read by the application; <code>false</code> otherwise<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - If a security manager exists and its <code><A HREF="../../java/lang/SecurityManager.html#checkRead(java.io.FileDescriptor)"><CODE>SecurityManager.checkRead(java.io.FileDescriptor)</CODE></A></code> method denies read access to the file</DL></DD></DL><HR><A NAME="canWrite()"><!-- --></A><H3>canWrite</H3><PRE>public boolean <B>canWrite</B>()</PRE><DL><DD>Tests whether the application can modify to the file denoted by this abstract pathname.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD><code>true</code> if and only if the file system actually contains a file denoted by this abstract pathname <em>and</em> the application is allowed to write to the file; <code>false</code> otherwise.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - If a security manager exists and its <code><A HREF="../../java/lang/SecurityManager.html#checkWrite(java.io.FileDescriptor)"><CODE>SecurityManager.checkWrite(java.io.FileDescriptor)</CODE></A></code> method denies write access to the file</DL></DD></DL><HR><A NAME="exists()"><!-- --></A><H3>exists</H3><PRE>public boolean <B>exists</B>()</PRE><DL><DD>Tests whether the file denoted by this abstract pathname exists.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD><code>true</code> if and only if the file denoted by this abstract pathname exists; <code>false</code> otherwise<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - If a security manager exists and its <code><A HREF="../../java/lang/SecurityManager.html#checkRead(java.io.FileDescriptor)"><CODE>SecurityManager.checkRead(java.io.FileDescriptor)</CODE></A></code> method denies read access to the file</DL></DD></DL><HR><A NAME="isDirectory()"><!-- --></A><H3>isDirectory</H3><PRE>public boolean <B>isDirectory</B>()</PRE><DL><DD>Tests whether the file denoted by this abstract pathname is a directory.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD><code>true</code> if and only if the file denoted by this abstract pathname exists <em>and</em> is a directory; <code>false</code> otherwise<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - If a security manager exists and its <code><A HREF="../../java/lang/SecurityManager.html#checkRead(java.io.FileDescriptor)"><CODE>SecurityManager.checkRead(java.io.FileDescriptor)</CODE></A></code> method denies read access to the file</DL></DD></DL><HR><A NAME="isFile()"><!-- --></A><H3>isFile</H3><PRE>public boolean <B>isFile</B>()</PRE><DL><DD>Tests whether the file denoted by this abstract pathname is a normal file. A file is <em>normal</em> if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD><code>true</code> if and only if the file denoted by this abstract pathname exists <em>and</em> is a normal file; <code>false</code> otherwise<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - If a security manager exists and its <code><A HREF="../../java/lang/SecurityManager.html#checkRead(java.io.FileDescriptor)"><CODE>SecurityManager.checkRead(java.io.FileDescriptor)</CODE></A></code> method denies read access to the file</DL></DD></DL><HR><A NAME="isHidden()"><!-- --></A><H3>isHidden</H3><PRE>public boolean <B>isHidden</B>()</PRE><DL><DD>Tests whether the file named by this abstract pathname is a hidden file. The exact definition of <em>hidden</em> is system-dependent. On UNIX systems, a file is considered to be hidden if its name begins with a period character (<code>'.'</code>). On Win32 systems, a file is considered to be hidden if it has been marked as such in the filesystem.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD><code>true</code> if and only if the file denoted by this abstract pathname is hidden according to the conventions of the underlying platform<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - If a security manager exists and its <code><A HREF="../../java/lang/SecurityManager.html#checkRead(java.io.FileDescriptor)"><CODE>SecurityManager.checkRead(java.io.FileDescriptor)</CODE></A></code> method denies read access to the file<DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="lastModified()"><!-- --></A><H3>lastModified</H3><PRE>public long <B>lastModified</B>()</PRE><DL><DD>Returns the time that the file denoted by this abstract pathname was last modified.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>A <code>long</code> value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or <code>0L</code> if the file does not exist or if an I/O error occurs<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - If a security manager exists and its <code><A HREF="../../java/lang/SecurityManager.html#checkRead(java.io.FileDescriptor)"><CODE>SecurityManager.checkRead(java.io.FileDescriptor)</CODE></A></code> method denies read access to the file</DL></DD></DL><HR><A NAME="length()"><!-- --></A><H3>length</H3><PRE>public long <B>length</B>()</PRE><DL><DD>Returns the length of the file denoted by this abstract pathname.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>The length, in bytes, of the file denoted by this abstract pathname, or <code>0L</code> if the file does not exist<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - If a security manager exists and its <code><A HREF="../../java/lang/SecurityManager.html#checkRead(java.io.FileDescriptor)"><CODE>SecurityManager.checkRead(java.io.FileDescriptor)</CODE></A></code> method denies read access to the file</DL></DD></DL>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -