try: public void writeTxt()
{
String sTemp = "aaaa中国";
String sPath = "c:\\text1.txt" ;
try
{
PrintWriter pw = new PrintWriter(new FileWriter(sPath, false), true);
pw.println(sTemp);
pw.close();
}
catch (Exception e)
{
System.out.println("error");
}
}
{
String sTemp = "aaaa中国";
String sPath = "c:\\text1.txt" ;
try
{
PrintWriter pw = new PrintWriter(new FileWriter(sPath, false), true);
pw.println(sTemp);
pw.close();
}
catch (Exception e)
{
System.out.println("error");
}
}
<%@ page import="java.io.*"%>
<% String st=request.getParameter("content");
try{
String sp=System.getProperty("file.separator");
String nameOfTextFile="d:"+sp+"jsp"+sp+"RESIN"+sp+"resin-2.0.2"+sp+"DOC"+sp+"TEACH"+sp+"op_masterresult.jsp";
//这里是路径和文件名
PrintWriter pw=new PrintWriter(new FileOutputStream(nameOfTextFile));
pw.println(st);
pw.close();}
catch(IOException e){out.print(e.getMessage());}
out.println(st);
%>