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

📄 file1.jsp

📁 一本jsp自学教材
💻 JSP
字号:
<%@ page contentType="text/HTML;charset=gb2312"%> 
<%@ page import="java.io.*"%> 
<HTML> 
<head> 
<title>文件的操作,属性</title> 
</head> 
<body> 
<% 
String path=request.getRealPath("/"); 
String newdir=path+"newdir";
out.print("文件路径为:"+path);

File f1=new File(path,"t1.txt");	
File f2=new File(path,"t2.txt"); 
if(!f1.equals(f2))
{
f2.delete();
}
File f3=new File(newdir);
out.print("<BR>F2::exists:"+f2.exists());
out.print("<BR>F3:isFile:"+f3.isFile());
out.print("<BR>F3::exists:"+f3.exists());
if(!f3.isFile())  //检查目录不存在时创建新目录
{ 
f3.mkdir();//创建新目录 
f1.setReadOnly();
f2.createNewFile();
File tmpFile = new File(path+"china.txt");
f2.renameTo(tmpFile);
}
out.print("<BR>t1.txt:canRead:"+f1.canRead());
out.print("<BR>t1.txt:canWrite:"+f1.canWrite());
%>
</BODY>
</HTML>

⌨️ 快捷键说明

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