Java file operations Daquan 3: attributes of a document
Abstract: Java file operations Daquan 3: attributes of a document
</ Td> </ tr> <tr> <td width="513" height="35" valign="top" class="ArticleTeitle"> <% @ page contentType = "text / html; gb2312 charset ="% >
<% @ Page import = "java.util.Date, java.io. *"%>
<head>
</ Head>
<body>
<%
String path = request.getRealPath ( "/ article/article5a/example/filetest");
File f = new File (path, "ReadData.txt");
If (f.exists ()) (
%>
<% = F.getName ()%> attributes are as follows:
Document length: <% = f.length ()%>
<% = F.isFile ()? "Document": "No documents"%>
<% = F.isDirectory ()? "Directory": "not a directory"%>
<% = F.canRead ()? "Can be read": "Do not read"%>
<% = F.canWrite ()? "Write": "Do not write"%>
<% = F.isHidden ()? "Hidden files": "no hidden files"%>
The document was last modified date: <% = new Date (f.lastModified ())%>
<%
Else ()
F.createNewFile ();// under the current directory creation of a document entitled ReaData.txt
%>
<% = F.getName ()%> attributes are as follows:
Document length: <% = f.length ()%>
% = F.isFile ()? "Document": "No documents"%>
<% = F.isDirectory ()? "Directory": "not a directory"%>
<% = F.canRead ()? "Can be read": "Do not read"%>
<% = F.canWrite ()? "Write": "Do not write"%>
<% = F.isHidden ()? "Hidden files": "no hidden files"%>
The document was last modified date: <% = new Date (f.lastModified ())%>
<%
)
%>
</ Body>
</ Td> <td width="171" valign="top" class="ArticleTeitle">
</ Td> </ tr> <tr> <td height="25" colspan="2" valign="top" class="ArticleTeitle">
↑ Back
Tags: File






