⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sample6.jsp

📁 jsp学习的好资料
💻 JSP
字号:
<%@ page language="java" contentType="text/html; charset=gb2312"%> 
<%@ page import="java.io.*"%> 
<html>
	<head>
		<title>判断是文件还是文件夹</title>
	</head>	
	<body>
<%
	String path = request.getRealPath("/");
	String a_path = path+"a";
	File fp1 = new File(a_path);
	fp1.mkdir();
	String b_path = a_path+"\\b";
	File fp2 = new File(b_path);
	fp2.mkdir();
	File fp3 = new File(a_path,"c.txt");
	fp3.createNewFile();
	File fp4 = new File(a_path,"d.txt");
	fp4.createNewFile();
	File fp5 = new File(a_path);
	File filelist[]=fp5.listFiles();
%>	
		<center>
			文件夹<%=a_path%><br>
			中有以下文件夹和文件:<br>
			<%
				for(int i=0; i<filelist.length; i++)
					{	
			%>
			<% 
				out.println(filelist[i].getName());
				if(filelist[i].isDirectory()) out.println("是文件夹");
				if(filelist[i].isFile()) out.println("是文件");
			%><br>
			<%}%>
		</center>
	</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -