MyEclipse------如何在特定目录下创建文件夹

时间:2023-01-21 18:09:22

Directory.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@page import="java.io.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'Directory.jsp' starting page</title>
</head>

<body>
    <%
        path=request.getRealPath("")+"\\test";
        File d=new File(path);
        if(d.exists()){
            d.delete();
            out.print("test文件夹已经被删除!!!");
        }
        else{
            d.mkdir();
            out.print("test文件夹已经被创建!!!");
        }
     %>
</body>
</html>