注册 登录
编程论坛 J2EE论坛

新建文件问题

HB515560244 发布于 2007-10-26 18:30, 485 次点击

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ page import="java.io.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'MyJsp9.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>
<%
File dir=new File("C:/","Upload");
boolean a=dir.mkdir();
File f =new File(dir,"java.txt");
%>
<body>
This is my JSP page. <br>
<%= a %>
</body>
</html>


如题,为什么在我的Upload目录下没java.txt文件啊?

是哪里出现问题吗?还是  不是这样做,我就想新建一个文件

2 回复
#2
HB5155602442007-10-26 21:06

晕。在这个论坛发表了这么都多的问题,竟然没一个人回答,是我的问题难还是我的问题幼稚???
问题再简单,高手们留个言也好啊,

#3
netstriker2007-10-27 09:19
今天是星期六啊,高手都放假去了,因为我不是高手所以节假日不休息 ,
你上边的代码加上
f.createNewFile();
就可以了,我测试通过。如果再有什么问题可以再提出来。
1