jsp文件操作的问题

来源:百度知道 编辑:UC知道 时间:2024/09/22 23:31:37
程序如下:用FileWriter和FileReader进行文件的操作
<%
char a[]={'你','好'};
char b[]=new char[2];
File f=new File("e:/jsp","temp.txt");
if(f.exists()){}
else
f.createNewFile();
try{FileWriter fw=new FileWriter(f);}
catch(IOException e)
{out.println("File is error"+e);}
fw.write(a);
try{FileReader fr=new FileReader(f);}
catch(IOException e)
{out.println("File is error"+e);}
fr.reader(b);
String art=new String(b,0);
out.println(art);
%>
为什么会出错?
错误提示是这个:
An error occurred at line: 10 in the jsp file: /h2.jsp
Generated servlet error:
Invalid character constant

An error occurred at line: 10 in the jsp file: /h2.jsp
Generated servlet error:
Invalid character constant

Generated servlet error:
Syntax error, insert "}" to complete ClassBody

出什么错误 发上来 让我看看
这个错误是说 你的第10行有 无效的代码 你好好看看你的 catch 里的代码 你那e是啥 啊 迷糊
try
{

}catch(IOException e)
{
System.out.println(e.getMessage);
}
不是e 你试试我写的这个

一般在JSP中很少去写这样的代码的!通常是写在Servlet中的!还有你的错误信息是什么呢?把你的错误信息发过来看下就知道是什么问题了!