javaÎļþ²Ù×÷´óÈ«
ÎļþµÄ½¨Á¢/¼ì²éÓëɾ³ý
£¼%@ page contentType="text/html;charset=gb2312"%>
£¼%@ page import="java.io.*"%>
£¼html>
£¼head>
£¼title>ÎļþµÄ½¨Á¢¡¢¼ì²éÓëɾ³ý£¼/title>
£¼/head>
£¼body>
£¼%
String path=request.getRealPath("");
//out.println(path);
File f=new File(path,"File.txt");
//out.println(f);
//out.println(f.exists());
if(f.exists()){//¼ì²éFile.txtÊÇ·ñ´æÔÚ
f.delete();//ɾ³ýFile.txtÎļþ
out.println(path + "\\File.txt ´æÔÚ£¬ÒÑɾ³ý¡£");
}else{
f.createNewFile();//ÔÚµ±Ç°Ä¿Â¼Ï½¨Á¢Ò»¸öÃûΪFile.txtµÄÎļþ
out.println(path + "\\File.txt ²»´æÔÚ£¬Òѽ¨Á¢¡£");//Êä³öĿǰËùÔÚµÄĿ¼·¾¶
}
%>
Ŀ¼µÄ½¨Á¢/¼ì²éÓëɾ³ý
£¼%@ page contentType="text/html;charset=gb2312"%>
£¼%@ page import="java.io.*"%>
£¼html>
£¼head>
£¼title>Ŀ¼µÄ½¨Á¢/¼ì²éÓëɾ³ý£¼/title>
£¼/head>
£¼body>
£¼%
String path=request.getRealPath("");
path=path + "\\Sub";//½«Òª½¨Á¢µÄĿ¼·¾¶
File d=new File(path);//½¨Á¢´ú±íSubĿ¼µÄFile¶ÔÏ󣬲¢µÃµ½ËüµÄÒ»¸öÒýÓÃ
if(d.exists()){//¼ì²éSubĿ¼ÊÇ·ñ´æÔÚ
d.delete();
out.println("SubĿ¼´æÔÚ£¬ÒÑɾ³ý");
}else{
d.mkdir();//½¨Á¢SubĿ¼
out.println("SubĿ¼²»´æÔÚ£¬Òѽ¨Á¢");
}
%>
£¼/body>
£¼/html>
[1] [2] [3] [4] [5] [6] ÏÂÒ»Ò³