zoukankan      html  css  js  c++  java
  • MyEclipse------File类的各种方法

    usingFile.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 'usingFile.jsp' starting page</title>
    </head>
    
    <body>
        <!-- String thePath=request.getRealPath("");作用:获取取得你当前运行文件在服务器上的绝对路径 -->
        <%
            //path=request.getRealPath("");
            //out.println(path);
            //String pathe=request.getRealPath("/");
            //out.print(pathe);
         %>
         <br>
        <%
            String thePath=request.getRealPath("")+"\file";
            out.print(thePath+"<br>");
            File dir=new File(thePath);
            File myFile=new File(thePath,"usingFile.jsp");
            File notExitFile=new File(thePath,"file.txt");
            out.print("目录"+thePath+"是否存在:  "+dir.exists()+"<br><br>");
            out.print("文件"+thePath+"\usingFile.jsp是否存在:  "+myFile.exists()+"<br><br>");
            out.print("文件"+thePath+"\file.txt是否存在:  "+notExitFile.exists()+"<br><br>");
            out.print("文件"+thePath+"\usingFile.jsp是否可读:  "+myFile.canRead()+"<br><br>");
            out.print("文件"+thePath+"\usingFile.jsp是否可写:  "+myFile.canWrite()+"<br>");
         %>
    </body>
    </html>
  • 相关阅读:
    InstallShield自定义对话框模板代码(转)
    破解汇编知识(转)
    Openrowset数据库远程操作
    SQL类似sleep延时语句
    C#结束线程
    JavaScript中相应ActiveX事件
    Visual C# .NET 命令行编辑器
    AfxBeginThread
    atoi,atol,strtod,strtol,strtoul类型转换(转)
    SQLServer PadLeft,PadRight
  • 原文地址:https://www.cnblogs.com/tianhengblogs/p/5325133.html
Copyright © 2011-2022 走看看