快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

一个读取文件和子目录列表的程序

<%@ page language=javascript %><html>
<!-- dir.jsp
-- Creates a page recursively listing all subdirectories and files.
-->
<head><title>Directory Listing</title></head>
<body bgcolor=#ffffff>

<h1>Directory Listing</h1>

<%
//
// Resin file I/O roughly follows java.io with the exceptions:
// 1) All filenames are urls using \\\'/\\\' as the filename separator.
// 2) The myriad stream classes, readers, and writers are coalesced
// into a single stream object.
//
// This function recursively lists the directory contents.
//
// Example:
//
// top
// <ul>
// <li>sub1
// <li>sub2
// <ul>
// <li>subsub
// </ul>
// </ul>
//
function readdir(path)
{
out.writeln(path.path.split(\\\'/\\\').reverse()[0]);
if (path.isDirectory()) {
out.writeln("<ul>");
for (file in path.list()) {
out.write("<li>");
readdir(path(file));
}
out.writeln("</ul>");
}
}

readdir(File("data"));

%>

</body>
</html>
返回类别: 教程
上一教程: JSP访问数据库的问题整理
下一教程: 四、处理表单数据

您可以阅读与"一个读取文件和子目录列表的程序"相关的教程:
· java程序的递归算法,列出某个目录下的所有子目录和文件
· 用JSP编写文件上传的程序
· 一个向数据库存取IMAGE文件的JSP程序
· JSP中读取远程机器的PROPERTIES文件和IP地址
· 从JAVA档案(JAR)中读取文件
    微笑服务 优质保证 索取样品