【JSP开源代码栏目提醒】:网学会员,鉴于大家对JSP开源代码十分关注,论文会员在此为大家搜集整理了“FileAttr.jsp”一文,供大家参考学习!
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<%@ page import="java.util.Date,java.io.*"%>
<html>
<head>
<title>获取文件属性</title>
</head>
<body>
<%
request.setCharacterEncoding("gb2312");
String fileName=request.getParameter("filename");
fileName = "c:\\temp\\" + fileName;
File f=new File(fileName);
%>
<center>
<h4><%=fileName %>的详细属性为</h4>
<table border="1">
<tr>
<td>属性</td><td>值 </td>
</tr>
<tr><td>文件长度</td><td><%=f.length()%></td></tr>
<tr><td>是否是文件</td><td><%=f.isFile()?"是文件":"不是文件"%></td></tr>
<tr><td>是否为目录</td><td><%=f.isDirectory()?"是目录":"不是目录"%></td></tr>
<tr><td>是否可读取</td><td><%=f.canRead()?"可读取":"不可读取"%></td></tr>
<tr><td>是否可写入</td><td><%=f.canWrite()?"可写入":"不可写入"%></tr>
<tr><td>是否是隐藏文件</td><td><%=f.isHidden()?"是隐藏文件":"不是隐藏文件"%></td></tr>
<tr><td>文件的最后修改日期</td><td><%=new Date(f.lastModified())%></td></tr>
</table>
</center>
</body>
</html>