<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.io.*"%>
<html>
<body Bgcolor=cyan><FONT size=3>
<%
File f=new File("D:/","A.java");
if(f.exists())
{
f.delete();
}
else
{
f.createNewFile();
}
<%
out.print("File name:"+f.getName());
out.print("File path:"+f.getPath());
%>
</font>
</body>
</html>
<%@ page import="java.io.*"%>
<html>
<body Bgcolor=cyan><FONT size=3>
<%
File f=new File("D:/","A.java");
if(f.exists())
{
f.delete();
}
else
{
f.createNewFile();
}
<%
out.print("File name:"+f.getName());
out.print("File path:"+f.getPath());
%>
</font>
</body>
</html>
解决方案 »
- 高级问题:js已经得到对象,但是却没有向下执行
- 加载驱动异常,请帮忙看下,
- JSF中<f:subview>子页面中的commandLink不能跳转到新的页面,怎么解决?
- jsp连接access不能进行新增 修改 删除 急啊 摆脱高手看看
- 蓝蓝进来呀~~~花花送分了~
- @@@@@@@希望高手提点一下,急啊@@@@@@@@@出现了java.io.Serializable Exception....数据库连接池不起作用了,没有连接到数据库。
- 急!!各位大哥哥快点帮帮小MM吧!
- 调用了ResultSet rs=stmt.executeQuery(sql)后再调用rs.wasNull出现的异常
- 软件下载问题,高手请进!
- 找到一个好地方支持jsp,但只有30天试用,谁知道更好的
- 一个action的对象存在多长时间?
- 我在国外做web developer,私下里也会接活,有国内的朋友愿意合作吗?
<%@ page import="java.io.*"%>
<html>
<body Bgcolor=cyan><FONT size=3>
<%
File f=new File("D:/","A.java");
if(f.exists())
{
f.delete();
}
else
{
f.createNewFile();
}
<%--------去掉或者修改成:%> <%
out.print("File name:"+f.getName());
out.print("File path:"+f.getPath());
%>
</font>
</body>
</html>
<%@ page import="java.io.*"%>
<html>
<body Bgcolor=cyan><FONT size=3>
<%
File f=new File("D:/","A.java");
File dir=new File("D:/","TIANKANGLE");
if(f.exists()&dir.exists())
{
f.delete();
dir.delete();
}
else
{
f.createNewFile();
dir.createNewFile();
}out.print("File name:"+f.getName());
out.print("File path:"+f.getPath());
out.print("文件名:"+dir.getName());
out.print("路径:"+dir.getPath());
%>
</font>
</body>
</html>
这样写出来显示正常:
File name:A.java File path:D:\A.java File name:TIANKANGLE File path:D:\TIANKANGLE 用什么可以让这段回车到下行.File name:TIANKANGLE File path:D:\TIANKANGLE
out.print("File path:"+f.getPath());
<br>
out.print("文件名:"+dir.getName());
out.print("路径:"+dir.getPath());这样加的话不行,提示:
description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 5 in the jsp file: /t5.jsp
Generated servlet error:
Syntax error on token(s), misplaced construct(s)
out.print("File path:"+f.getPath() + "<BR>");out.print("文件名:"+dir.getName());
out.print("路径:"+dir.getPath());
<%@ page import="java.io.*"%>
<html>
<body Bgcolor=cyan><FONT size=3>
<%
File f=new File("D:/","A.java");
if(f.exists())
{
f.delete();
}
else
{
f.createNewFile();
}
out.println("File name:"+f.getName()+boolean b1=f.delect());
out.println("File path:"+f.getPath());%>
<p>文件A.java成功删除了吗?
<%=b1%></font>
</body>
</html>
这样的语方对吗?