<%
String firstName = request.getParameter("T1");
try{
PrintWriter fileOut=new PrintWriter(new FileWriter//同一行("lovexing.txt",true)); //同一行
fileOut.println(firstName);
fileOut.close();
}
catch(IOException ioExc){
}
%>这是简单例子,目的知道原理而已,但绝对不够的,
还有换行问题,自己搞定,这个不难
生成的文件名为lovexing.txt,经过测试,
这文件出现在c:\winnt\system32(我用的windows2k)
String firstName = request.getParameter("T1");
try{
PrintWriter fileOut=new PrintWriter(new FileWriter//同一行("lovexing.txt",true)); //同一行
fileOut.println(firstName);
fileOut.close();
}
catch(IOException ioExc){
}
%>这是简单例子,目的知道原理而已,但绝对不够的,
还有换行问题,自己搞定,这个不难
生成的文件名为lovexing.txt,经过测试,
这文件出现在c:\winnt\system32(我用的windows2k)
再送你一个换行问题的Bean,
你引入它后,直接toBr方法就可以的了
package test;public class ToBrBean{
public static String toBr(String sStr){
StringBuffer sTmp=new StringBuffer();
int i=0;
if(sStr==null||sStr.equals("")){
return sStr;
}
while (i<=sStr.length()-1){
if(sStr.charAt(i)=='\n'){
sTmp=sTmp.append("<br>");
}
else if(sStr.charAt(i)==' ')
sTmp=sTmp.append(" ");
else
sTmp=sTmp.append(sStr.substring(i,i+1));
i++;
}
sStr=sTmp.toString();
return sStr;
}
}